You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nix-locate crashes if you try to pipe the results in bash.
Only breaks if there is more then one result returned by nix-locate.
Steps to reproduce
nix-locate libQt5Xml.so.5 | head -n 1
Technical details
$ nix-locate libQt5Xml.so.5 | head -1
robomongo.out 0 s /nix/store/arnj25h57nqjixwc4nx12ad6fsz8jls1-robo3t-1.1.1/lib/robo3t/lib/libQt5Xml.so.5
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', libstd/io/stdio.rs:692:9
note: Run with RUST_BACKTRACE=1 for a backtrace.
Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.
system: "x86_64-linux"
host os: Linux 4.19.17, NixOS, 18.09.1985.749a3a0d00b (Jellyfish)
This symptom was reported to rust-lang/rust#46016 1+ year ago, and although Rust still doesn't provide a way to change this behavior, there are some suggested solutions there for applications which are affected like this.
The portable way to make the error go away is to replace println! with writeln! (similarly for print!) and check the returned Result. In this case the failing calls are in fn locate(). First get a handle for stdout:
let stdout = std::io::stdout();letmut handle = stdout.lock();
Then replace each println!(...) with something like:
(because nix-locate should just silently exit in this case; it isn't really an error that should be propagated up with ?.)
Would you like to write a patch for this? I'm not the maintainer so I can't promise it would be merged, but personally, I certainly think this is worth fixing.
Issue description
nix-locate crashes if you try to pipe the results in bash.
Only breaks if there is more then one result returned by nix-locate.
Steps to reproduce
nix-locate libQt5Xml.so.5 | head -n 1
Technical details
$ nix-locate libQt5Xml.so.5 | head -1
robomongo.out 0 s /nix/store/arnj25h57nqjixwc4nx12ad6fsz8jls1-robo3t-1.1.1/lib/robo3t/lib/libQt5Xml.so.5
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', libstd/io/stdio.rs:692:9
note: Run with
RUST_BACKTRACE=1
for a backtrace.Please run
nix-shell -p nix-info --run "nix-info -m"
and paste theresults.
"x86_64-linux"
Linux 4.19.17, NixOS, 18.09.1985.749a3a0d00b (Jellyfish)
yes
yes
nix-env (Nix) 2.1.3
"nixos-18.09.1985.749a3a0d00b, nixos-unstable-19.03pre166987.bc41317e243"
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: