fix(compile): enable ANSI colors on Windows in compiled binaries#34701
Merged
Conversation
`deno compile` embeds the denort runtime (cli/rt), whose main() did not enable ANSI virtual terminal processing on Windows, unlike the main deno binary. On consoles that don't enable it by default (Windows Server 2022, classic conhost) compiled executables printed raw ANSI escape codes instead of colored output, while `deno run` worked. Mirror the `colors::enable_ansi()` call from the main entrypoint. Closes #29875
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29875.
Since Deno 2.2.6,
deno compile'd executables print raw ANSI escape codesinstead of colored output on Windows consoles that do not enable virtual
terminal processing by default, such as Windows Server 2022 and the classic
conhost.
deno runis unaffected.The cause is that a compiled binary does not run the normal
denoentrypoint. It embeds the denort runtime in
cli/rt, which has its ownmain(). The maindenobinary enables ANSI on Windows viacolors::enable_ansi()(incli/lib.rs), but denort'smain()never did,so the console was never switched into virtual terminal mode and treated the
escape sequences literally. The new Windows Terminal enables VT processing
itself, which is why the regression only shows on older or server consoles.
This mirrors the
colors::enable_ansi()call into denort'smain()behind#[cfg(windows)], matching what the main binary already does.Note: this is Windows console behavior and cannot be reproduced on macOS or
Linux, so it should be validated on a Windows Server / non Windows Terminal
console before merge.