-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
C-bugCategory: bugCategory: bug
Description
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.com-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
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
weihanglo commentedon Dec 4, 2021
I saw it fixed on clap v2.33.4. Really great!
clap-rs/clap@accf3d2
ehuss commentedon Dec 4, 2021
Thanks @weihanglo, would you mind posting a PR that updates our
Cargo.toml
to "2.34.0"?Auto merge of #10164 - weihanglo:issue-10131, r=ehuss