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

Cargo prints rustc's stderr twice #4223

Closed
Mark-Simulacrum opened this issue Jun 25, 2017 · 5 comments · Fixed by #4230
Closed

Cargo prints rustc's stderr twice #4223

Mark-Simulacrum opened this issue Jun 25, 2017 · 5 comments · Fixed by #4230
Assignees

Comments

@Mark-Simulacrum
Copy link
Member

This is primarily a problem for those who use this output and pipe to editors to jump from error to error. The cause of this is the fact that Cargo uses exec_with_streaming inside exec_json, and passes this stderror handler in. That prints out stderr upon receiving each line, which is fine -- we should do this. However, exec_with_streaming also saves this data here. This output is later printed in "process didn't execute successfully," leading to duplication of the stderr for the compiler.

Arguably, none of these individually are bad, but together they don't lead to optimal behavior. I think the easiest and most straightforward fix here is to add a flag to exec_with_streaming that prevents printing stderr when the command fails and pass it in from cargo_rustc.

cc @alexcrichton

cc @eddyb -- you asked on IRC about this

@matklad
Copy link
Member

matklad commented Jun 25, 2017

Hm, this is probably a regression: I remember seeing a similar problem with nightly Cargo recently, while stable printed error only once. I think this happened around after #4029.

@alexcrichton
Copy link
Member

Ah yeah Cargo shouldn't ever print anything out twice here! @Mark-Simulacrum I think you hit the nail head on. My preferred fix for this would be to stream output but not capture it. That way you get errors and other diagnostics as they come and we shouldn't duplicate anything.

@Mark-Simulacrum
Copy link
Member Author

I'll file a PR soon, hopefully.

@Mark-Simulacrum Mark-Simulacrum self-assigned this Jun 26, 2017
bors added a commit that referenced this issue Jun 27, 2017
Prevent rustc stderr/stdout from being duplicated.

Please review carefully. I've not submitted patches to Cargo before, I think, so this may be flawed in some way I haven't detected yet. Tests are green locally, though.

Fixes #4223
ehuss added a commit to ehuss/sublime-rust that referenced this issue Aug 16, 2017
Due to a bug (rust-lang/cargo#4223), Rust was
displaying the stdout of the compiler, causing the parsing code to get
confused.

Also, update tests for 1.19 message changes, and deprecation of no-trans.
jasonwilliams pushed a commit to rust-lang/rust-enhanced that referenced this issue Aug 19, 2017
* Add global Cargo settings for all packages.

* Fix a bug building with Rust 1.19.

Due to a bug (rust-lang/cargo#4223), Rust was
displaying the stdout of the compiler, causing the parsing code to get
confused.

Also, update tests for 1.19 message changes, and deprecation of no-trans.
urschrei pushed a commit to urschrei/sublime-rust that referenced this issue Jan 30, 2018
* Add global Cargo settings for all packages.

* Fix a bug building with Rust 1.19.

Due to a bug (rust-lang/cargo#4223), Rust was
displaying the stdout of the compiler, causing the parsing code to get
confused.

Also, update tests for 1.19 message changes, and deprecation of no-trans.
@flavius
Copy link

flavius commented May 4, 2019

There seems to be a regression on this with cargo 1.34.0 (6789d8a0a 2019-04-01) when it's building as part of cargo test -- --nocapture

@ehuss
Copy link
Contributor

ehuss commented May 4, 2019

@flavius Can you file a new issue with a reproduction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants