Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No console colors on Windows 7 #55769

Closed
jminer opened this issue Nov 7, 2018 · 14 comments · Fixed by #55788
Closed

No console colors on Windows 7 #55769

jminer opened this issue Nov 7, 2018 · 14 comments · Fixed by #55788
Labels
O-windows Operating system: Windows

Comments

@jminer
Copy link

jminer commented Nov 7, 2018

I just updated Rust at work, and now rustc has no colors in the console (Cargo still does). I'm using Windows 7 64-bit with Rust MSVC 32-bit. I tried 1.29 stable and it worked, but 1.30 stable and the latest nightly don't work. I have tried both cmd.exe and PowerShell and both look the same. This is a big regression in usability, so I'll probably downgrade back to a working version.

rustc_no_colors

@estebank estebank added the O-windows Operating system: Windows label Nov 7, 2018
@ehuss
Copy link
Contributor

ehuss commented Nov 8, 2018

I can confirm this happens on Windows 8, and can confirm it is caused by rust-lang/cargo#5862.
cc @kennytm, @alexcrichton

@kennytm
Copy link
Member

kennytm commented Nov 8, 2018

Will cargo run --color=always enable the colors?

@ehuss
Copy link
Contributor

ehuss commented Nov 8, 2018

--color=always does not seem to have an effect. It is passing --color=always to rustc, but for some reason rustc is not returning content with ANSI codes. If you run rustc manually on the command line, the colors seem to work.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 8, 2018
Currently Cargo will always capture the output of rustc meaning that
rustc is never hooked up to a tty. To retain colors Cargo uses the
`fwdansi` crate to ensure that ansi color codes are translated to
windows terminal methods (and ansi codes otherwise just go their natural
route on Unix).

Cargo passes `--color always` to rustc to ensure that using a pipe
doesn't trick it into not emitting colors at all. It turns out, however,
that `--color always` ends up still accidentally using the native shell
api on native windows shells.

The fix here is to instead pass `AlwaysAnsi` to `termcolor` instead of
`Always`, ensuring that when `--color always` is passed to rustc and its
output isn't a terminal, we're always generating ansi colors regardless
of the platform.

Closes rust-lang#55769
@alexcrichton
Copy link
Member

Thanks for the report @jminer! I think this'll get fixed by #55788

@kennytm I think we only tested msys shells earlier, right? I think we're hitting this branch of termcolor which I guess means that this is succeeding somehow. It's not entirely clear to me why that's all somehow not failing but I'm pretty sure that asking for AlwaysAnsi will do the trick

@kennytm
Copy link
Member

kennytm commented Nov 8, 2018

@alexcrichton previously i did have tested on cmd.exe, but i haven't followed the recent changes which might have broken it

@alexcrichton
Copy link
Member

Hm ok, that's worrisome! If #55788 doesn't do the trick I can try to investigate later, but it'll be quite awhile before I have a windows computer to test on again

kennytm added a commit to kennytm/rust that referenced this issue Nov 8, 2018
rustc: Request ansi colors if stderr isn't a tty

Currently Cargo will always capture the output of rustc meaning that
rustc is never hooked up to a tty. To retain colors Cargo uses the
`fwdansi` crate to ensure that ansi color codes are translated to
windows terminal methods (and ansi codes otherwise just go their natural
route on Unix).

Cargo passes `--color always` to rustc to ensure that using a pipe
doesn't trick it into not emitting colors at all. It turns out, however,
that `--color always` ends up still accidentally using the native shell
api on native windows shells.

The fix here is to instead pass `AlwaysAnsi` to `termcolor` instead of
`Always`, ensuring that when `--color always` is passed to rustc and its
output isn't a terminal, we're always generating ansi colors regardless
of the platform.

Closes rust-lang#55769
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Nov 9, 2018
rustc: Request ansi colors if stderr isn't a tty

Currently Cargo will always capture the output of rustc meaning that
rustc is never hooked up to a tty. To retain colors Cargo uses the
`fwdansi` crate to ensure that ansi color codes are translated to
windows terminal methods (and ansi codes otherwise just go their natural
route on Unix).

Cargo passes `--color always` to rustc to ensure that using a pipe
doesn't trick it into not emitting colors at all. It turns out, however,
that `--color always` ends up still accidentally using the native shell
api on native windows shells.

The fix here is to instead pass `AlwaysAnsi` to `termcolor` instead of
`Always`, ensuring that when `--color always` is passed to rustc and its
output isn't a terminal, we're always generating ansi colors regardless
of the platform.

Closes rust-lang#55769
@kennytm kennytm reopened this Nov 11, 2018
@alexcrichton
Copy link
Member

For posterity there was some discussion of why this isn't actually fixed on nightly right now, and @kennytm has a PR to termcolor which should fix this

@MSxDOS
Copy link

MSxDOS commented Jun 4, 2019

Any chance this is getting fixed in the nearest future?

@mati865
Copy link
Contributor

mati865 commented Jun 4, 2019

@MSxDOS I pinged termcolor author and he is reviewing PR mentioned above so this should get fixed on nightly soon.

@kennytm
Copy link
Member

kennytm commented Jun 4, 2019

Nah we still need to go through the package release and update Cargo.lock processes 🙃

@phansch
Copy link
Member

phansch commented Jun 4, 2019

When this gets fixed, is there a possibility of adding some sort of UI test for this? This would be helpful for ensuring colors continue to work, when implementing #59346

@moxian
Copy link
Contributor

moxian commented Jun 22, 2019

termcolor-1.0.5 was released containing the fix.
I thought I'd update Cargo.lock and PR the change, but I've built rustc with termcolor-1.0.5. and I still can't see the rustc color output when run by cargo. So either I did something wrong when updating/rebuilding rustc, or BurntSushi/termcolor#10 didn't fix the issue...

@ehuss
Copy link
Contributor

ehuss commented Jun 22, 2019

@moxian it should work, but there is a bug in Cargo where colors are not working correctly, so that's why I have not updated things here, yet. I filed kennytm/fwdansi#1 but I have not heard back from @kennytm, yet.

@ehuss
Copy link
Contributor

ehuss commented Jul 31, 2020

This should be fixed on the latest nightly (2020-07-31) via rust-lang/cargo#8540 and #74923.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants