Skip to content

volta -h panics when stdout is closed #1055

Description

@lopopolo
$ volta --version
Updating your Volta directory. This may take a few moments...
1.0.5
$ RUST_BACKTRACE=1 volta -h | false
thread 'main' panicked at 'Error writing Error to stdout: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/clap-2.33.0/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: clap::app::App::get_matches_from::{{closure}}
   6: clap::app::App::get_matches
   7: volta::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Clap provides a get_matches_from_safe API that returns a Result rather than panicking when failing to write to stdout.

Here's some MIT-licensed code I use in one of my projects that does this dance in a panic-free way:

https://github.com/artichoke/artichoke/blob/d527412f9438aeba4cadb1f4303237f6f9e0cd4d/src/bin/artichoke.rs#L138-L173

Activity

  1. lopopolo commented on Nov 29, 2021

    @lopopolo
    Author

    I've opened up this ticket with upstream clap to see if the maintainers are open to fixing this panic on the v2 branch:

  2. charlespierce commented on Nov 30, 2021

    @charlespierce
    Contributor

    Hi @lopopolo, thanks for reporting this! It looks, from the linked issue, like the underlying problem is solved in Clap v3. I suspect the best way forward for Volta will be to adopt Clap v3 once that is out of beta.

  3. chriskrycho commented on Dec 1, 2021

    @chriskrycho
    Contributor

    Looks like it was backported, so we should be able to just bump our version to latest Clap v2 and cute patch release.

  4. added a commit that references this issue on Dec 1, 2021
    43f6271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions