uutils/coreutils · error · std::io::Error
error writing 'standard output': {$err}
Error message
error writing 'standard output': {$err} What it means
Error "error writing 'standard output': {$err}" thrown in uutils/coreutils.
Source
Thrown at src/uu/head/src/head.rs:209
options.verbose = matches.get_flag(options::VERBOSE);
options.line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO));
options.presume_input_pipe = matches.get_flag(options::PRESUME_INPUT_PIPE);
options.mode = Mode::from(matches)?;
// #[allow(clippy::unwrap_used, reason = "clap provides '-' by default")] <https://github.com/rust-lang/rust/issues/15701>
options.files = matches
.get_many::<OsString>(options::FILES)
.unwrap()
.cloned()
.collect();
Ok(options)
}
}
#[inline]
fn wrap_in_stdout_error(err: io::Error) -> io::Error {
io::Error::new(
err.kind(),
translate!("head-error-writing-stdout", "err" => uucore::error::strip_errno(&err)),
)
}
// zero-copy fast-path
#[cfg(any(target_os = "linux", target_os = "android"))]
fn print_n_bytes(input: impl AsFd, n: u64) -> io::Result<u64> {
let out = io::stdout();
uucore::pipes::send_n_bytes(input, &out, n).map_err(wrap_in_stdout_error)
}
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn print_n_bytes(input: impl Read, n: u64) -> io::Result<u64> {
// Read the first `n` bytes from the `input` reader.
let mut reader = input.take(n);
// Write those bytes to `stdout`.View on GitHub (pinned to 8b8cbfd51b)
Solutions
- Check that stdout is writable and the consumer did not close the pipe (avoid SIGPIPE).
- Free disk space if the error is ENOSPC when stdout is redirected to a file.
When it happens
Trigger: Occurs when head fails to write to standard output, typically because stdout was closed early (EPIPE) or an I/O error occurred.
Common situations: Piping head into a command that exits immediately (e.g. `head -n100 file | true`), or redirecting output to a full or failing device.
AI-assisted analysis of uutils/coreutils@8b8cbfd51b (2026-08-19).
Data as JSON: /api/errors/dd308ae2b42646c4.
Report an issue: GitHub.