-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
stage1 compiler emits color information during x.py
build even when running with TERM=dumb
#49191
Comments
This patch solves the problem for me, but I don't know if it's the "right" thing to do:
|
Seems fine to me, I guess, but I'm also not sure whether it's the right thing to do -- maybe @BurntSushi happens to know if there's more detection other than "tty" that we should be doing? Is our detection faulty somehow, and that's why we're printing color when we shouldn't be? Is Cargo doing the right thing by-default with TERM=dumb? cc @killercup -- this is sort of in the CLI WG area (how do I detect whether color should be emitted?) |
From a behavioral standpoint, if TERM=dumb, then you definitely shouldn't emit colors. Ideally whatever color library you are using would do that detection automatically though? I don't have a lot of context on what the right patch is to the compiler though. IIRC, @alexcrichton recently did work in this area? |
In this case "library" is tty detection via copied code from somewhere -- https://github.com/rust-lang/rust/blob/master/src/bootstrap/compile.rs#L973-L994 -- which may be out of date and/or wrong. |
@BurntSushi to confirm, what would you expect to happen if |
Er sorry, I talked a bit with @nikomatsakis and it turns out that rustbuild is passing |
@alexcrichton Ah in that case I think I would expect the |
To better replicate Cargo's behavior it looks like we'll need to either depend on |
Ok cool just making sure! In that case I think this is a rustbuild "bug" rather than any other component. Rustbuild will configure an environment variable here which is read by our wrapper rustc script here. The problem is that rustbuild is passing All that put together means that when you run @Mark-Simulacrum I think this may be as simple as pulling in the |
I agree with @alexcrichton's analysis -- though egads what a hack. Anyway, the patch I write above hacks rustbuild. |
I think that patch is ~95% of what we want, though it may need to be expanded for Windows. I'm fine with just landing it though.
I think our copied unix/windows logic today is sufficient; we need termcolor's logic on TERM=dumb and perhaps a few more things on windows. I personally feel like checking for TERM=dumb will hold us until someone comes by again with this problem at which point we'll probably just switch to termcolor. |
@Mark-Simulacrum ah yes indeed! |
This issue only seems to have gotten worse. It now infects stage0 as well:
|
Should I open a PR with this patch ? |
These terminals generally don't support color. Fixes rust-lang#49191
I've now done so in #49809. |
sg, for now I'm using the patch locally... |
Stop emitting color codes on TERM=dumb These terminals generally don't support color. Fixes #49191 cc @nikomatsakis r? @alexcrichton
…r=alexcrichton Stop emitting color codes on TERM=dumb These terminals generally don't support color. Fixes rust-lang#49191 cc @nikomatsakis r? @alexcrichton
These terminals generally don't support color. Fixes rust-lang#49191
When I run
x.py
from inside emacs, everything works fine for the stage0 build. But errors that arise in the stage1 build always have color information. This is annoying since the emacs compilation window can't interpret ansi colors, so I get this garbage:It seems like the problem is this logic in rustbuild, which is a wee bit forceful:
rust/src/bootstrap/compile.rs
Lines 1004 to 1009 in a04b88d
Not sure what's the best way to fix this. I'm surprised that stderr is coming up as a "tty" when running from inside the M-x compile shell in emacs, but for sure the TERM variable is
dumb
. Maybe we should respect that?cc @Mark-Simulacrum
The text was updated successfully, but these errors were encountered: