Fix(error): Printing a new line to avoid overwriting error code after \r - #17373
Open
Suryansh-Dey wants to merge 1 commit into
Open
Fix(error): Printing a new line to avoid overwriting error code after \r#17373Suryansh-Dey wants to merge 1 commit into
Suryansh-Dey wants to merge 1 commit into
Conversation
Collaborator
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
epage
reviewed
Aug 18, 2026
| if is_quiet { | ||
| CliError::code(exit_code) | ||
| } else { | ||
| // Print a newline to stderr due to [this](https://github.com/rust-lang/cargo/issues/17343#issuecomment-5242201054). |
Contributor
There was a problem hiding this comment.
For myself, I prefer describing why inline instead of pointing to a comment, like
Ensure a newline between user and cargo's output, especially with trailing
"\r"
Contributor
Author
There was a problem hiding this comment.
Should I keep the URL in more like this?:
Ensure a newline between user and cargo's output, especially with trailing "\r". More
Once I get your opinion I am ready to proceed
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.
What does this PR try to resolve?
Closes #17343
Changes:
Added newline using
writeln!(gctx.shell().err());Reason:
Could have used
format!("\n{err}")but if there's an in-progress status line,gctx.shell().err()would erase it then print a newline. If you want I can switch toformatoption but this feels practically safer.How to test and review this PR?
cargo test -p cargo --test testsuite -- run::exit_code run::exit_code_verboseAnd both the tests passes.then run

cargo run. It prints error message just below.(Compiling for windows almost killed my laptop)
Before (current cargo on windows)