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

Crash on rye --version | head -1 #861

Closed
dalf opened this issue Mar 10, 2024 · 5 comments · Fixed by #862
Closed

Crash on rye --version | head -1 #861

dalf opened this issue Mar 10, 2024 · 5 comments · Fixed by #862

Comments

@dalf
Copy link

dalf commented Mar 10, 2024

Steps to Reproduce

Run rye --version | head -1

Expected Result

rye 0.28.0

Actual Result

rye 0.28.0
thread 'main' panicked at library/std/src/io/stdio.rs:1021:9:
failed printing to stdout: Broken pipe (os error 32)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Version Info

rye 0.28.0
commit: 0.28.0 (c44dc7ec8 2024-03-07)
platform: linux (x86_64)
self-python: cpython@3.12.1
symlink support: true
uv enabled: false

Stacktrace

thread 'main' panicked at library/std/src/io/stdio.rs:1021:9:
failed printing to stdout: Broken pipe (os error 32)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: std::io::stdio::print_to
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/io/stdio.rs:1021:9
   3: std::io::stdio::_print
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/io/stdio.rs:1097:5
   4: rye::cli::print_version
   5: rye::cli::execute
   6: rye::main
@mitsuhiko
Copy link
Collaborator

Hah. You ran into one of the odd outcomes of stdio in Rust. Since println! is infallible it just panics when the target stream is closed which basically happens in this case. Fixing this might require replacing println! with a custom macro in Rye that somehow closes the process instead.

@mitsuhiko
Copy link
Collaborator

Really hate the solution I have in place at the moment.

For alternative approaches see rust-lang/rust#46016

@weihanglo
Copy link

An alternative could be a custom wrapper of print macros, and disallow std marcos in clippy

https://rust-lang.github.io/rust-clippy/master/index.html#/disallowed_macros

@mitsuhiko
Copy link
Collaborator

Most uses of printing are already wrapped via the echo! macro so that would be an option.

@weihanglo
Copy link

Totally forgot. print_stdout and print_stderr lints might be better, pairing with allow-print-in-tests config. That is how Cargo does.

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.

3 participants