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 --help panics when stdout is closed #10131

Closed
lopopolo opened this issue Nov 29, 2021 · 2 comments · Fixed by #10164
Closed

cargo --help panics when stdout is closed #10131

lopopolo opened this issue Nov 29, 2021 · 2 comments · Fixed by #10164
Labels
C-bug Category: bug

Comments

@lopopolo
Copy link

Problem

cargo --help panics when stdout is closed.

There is a discussion about this API papercut upstream: clap-rs/clap#3055.

Steps

$ RUST_BACKTRACE=1 cargo --help | false
thread 'main' panicked at 'Error writing Error to stdout: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /Users/runner/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/clap-2.33.3/src/errors.rs:401:55
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::result::Result<T,E>::expect
   4: clap::errors::Error::exit
   5: cargo::exit_with_error
   6: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Possible Solution(s)

Use the App::get_matches_from_safe API and manually handle the error it returns, suppressing failures to write to either stdout or stderr.

Notes

No response

Version

cargo 1.56.0 (4ed5d137b 2021-10-04)
release: 1.56.0
commit-hash: 4ed5d137baff5eccf1bae5a7b2ae4b57efad4a7d
commit-date: 2021-10-04
@lopopolo lopopolo added the C-bug Category: bug label Nov 29, 2021
@weihanglo
Copy link
Member

I saw it fixed on clap v2.33.4. Really great!
clap-rs/clap@accf3d2

@ehuss
Copy link
Contributor

ehuss commented Dec 4, 2021

Thanks @weihanglo, would you mind posting a PR that updates our Cargo.toml to "2.34.0"?

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

Successfully merging a pull request may close this issue.

3 participants