Repository navigation
Closed
Labels
category:regressionSomething that worked does not work anymore.panictestsissues to add tests or fix tests
Description
Describe the bug
As title, while looking into an issue, I suddenly find out nushell panic when running testbin with first or last.
How to reproduce
run the given command: nu --testbin cococo 1 2 3 | first or nu --testbin cococo 1 2 3 | last
Expected behavior
I expect nu to show error message and not panic.
Screenshots
Configuration
| key | value |
|---|---|
| version | 0.92.3 |
| branch | main |
| commit_hash | 57b0c72 |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.77.2 (25ef9e3d8 2024-04-09) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.77.2 (e52e36006 2024-03-26) |
| build_time | 2024-04-18 06:26:33 +08:00 |
| build_rust_channel | debug |
| allocator | mimalloc |
| features | default, sqlite, trash, which |
| installed_plugins |
Additional context
Here is the backtrace I get:
Error: × Main thread panicked.
├─▶ at library/std/src/io/stdio.rs:1030:9
╰─▶ failed printing to stdout: Broken pipe (os error 32)
0: 0x5648a8039e14 - rust_begin_unwind at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647
1: 0x5648a806ab65 - core::panicking::panic_fmt::ha6effc2775a0749
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72
2: 0x5648a802fc98 - std::io::stdio::print_to::hec970441a5e8c603
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/stdio.rs:1030
- std::io::stdio::_print::h289ecbd691b224da
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/stdio.rs:1106
3: 0x5648a4f1b966 - nu::test_bins::cococo::hb38ee0f9c07a0471
at /home/windsoilder/projects/nushell/src/test_bins.rs:82
4: 0x5648a4f0ad13 - nu::main::hc234e957e379aef3
at /home/windsoilder/projects/nushell/src/main.rs:316
5: 0x5648a4f2c14b - core::ops::function::FnOnce::call_once::hcc040c3051d4cb6d
at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:250
Metadata
Metadata
Assignees
Labels
category:regressionSomething that worked does not work anymore.panictestsissues to add tests or fix tests

Activity
WindSoilder commentedon Apr 17, 2024
Nushell also shows a strangely BrokenPipe message if I run a script with
firstcommand:Then running
nu test.nu | firstgives me this output:devyn commentedon Apr 18, 2024
I think this is just because the testbins are not written with proper error handling. Writing to a pipe that's closed will cause an error, but nushell usually just exits silently in that case. It requires explicit handling though. This is a panic in the testbins, not in the engine itself
WindSoilder commentedon Apr 18, 2024
Hmm...I'm not totally agree with it, I still think there is something not right in engine.
For the given example in my comment:
nu test.nu | firstIt should not print out these error message:
It works fine on 0.91.
And strangely enough, if I'm in 0.91, and I run

nu --testbin cococo a b c | first(the nu is 0.92 or latest main), it doesn't panic eitherdevyn commentedon Apr 19, 2024
That's interesting, I'll have a look then.
Don't allow skip on external stream (#12559)
weirdan commentedon Aug 26, 2024
This doesn't seem to be happening anymore
devyn commentedon Aug 26, 2024
There have been a lot of changes since then, so I assume it's probably been fixed