nushell / nushell/nushell

`save` closed pipe before stream end

Open
#10,454 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:external-commands A:file-system A:redirection-pipe status:more-information-needed status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

I ran a rust program that prints to stdout, piping that output to save -f output.txt. The program crashed with the following error:

thread 'main' panicked at 'failed printing to stdout: The pipe is being closed. (os error 232)', library\std\src\io\stdio.rs:1019:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I suspect that the fault is with nu and not with my program or executing environment, but I am unsure, and have only seen this issue very rarely.

How to reproduce
  1. my_rust_program | save -f $output_file
Expected behavior

Write my output to file, closing the stream when writing has finished.

Screenshots

No response

Configuration
key value
version 0.85.1
branch main
commit_hash 7cfd4d2cfabca8f26e8bd1f84125bc256b650787
build_os windows-x86
build_target i686-pc-windows-msvc
rust_version rustc 1.70.0 (90c541806 2023-05-31)
rust_channel 1.70.0-i686-pc-windows-msvc
cargo_version cargo 1.70.0 (ec8a8a0ca 2023-04-25)
build_time 2023-09-21 09:48:44 +08:00
build_rust_channel release
allocator mimalloc
features default, extra, sqlite, trash, which, zip
installed_plugins
Additional context

if it's relevant, I'm running on windows 10 without WSL.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing my_rust_program | save -f $output_file on Windows, then trace the save command's stream handling. Confirm whether the output pipe closes before the producer finishes, and add or update coverage if the relevant test location is found; done means the Rust program completes without the broken-pipe panic and the file contains all output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.