atuinsh/atuin · error
failed printing to stdout
Error message
failed printing to stdout: {e} What it means
When Atuin writes the shell init script (e.g. `atuin init bash`) to stdout, a write failure surfaces here. `write!` on a locked stdout returns an error instead of panicking, so the code panics manually to preserve the historic `println!` panic message.
Solutions
- Ensure stdout is open and its consumer is still reading
- Avoid piping init output into commands that exit early (e.g. `| head`) — use `eval "$(atuin init bash)"` instead
- Check disk space if stdout is redirected to a file
- Capture the io::Error `{e}` in the panic for the real cause
Example fix
// before atuin init bash | head -20 // after eval "$(atuin init bash)"
Defensive patterns
Strategy: try-catch
Try / catch
match std::panic::catch_unwind(|| atuin::command::client::init::bash::init_static(&opts)) {
Ok(_) => {},
Err(_) => eprintln!("atuin init failed: stdout not writable"),
}
// or avoid the failure: consume stdout fully instead of piping to early-exiting commands Prevention
- Don't pipe `atuin init` into commands that close the pipe early
- Use `eval "$(atuin init bash)"` in shell rc files
- Keep stdout targets (files/disks) healthy
When it happens
Trigger: `atuin init <shell>` (via init_static) when the underlying write to stdout fails — closed stdout, broken pipe, or full disk.
Common situations: Piping `atuin init bash` into `head` or a closed consumer, redirecting stdout to a full filesystem, or a terminal that has gone away.
Related errors
- Atuin running with no parent!
- clone pty reader
- Could not build config
- Could not build default
- Could not deserialize config
AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19).
Data as JSON: /api/errors/65aee3b5600a3c7c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/atuin/src/command/client/init/bash.rs:53
write_tmux_config(writer, options.tmux)?;
writeln!(writer, "__atuin_bind_ctrl_r={bind_ctrl_r}")?;
writeln!(writer, "__atuin_bind_up_arrow={bind_up_arrow}")?;
writeln!(writer, "{}", BASH.main)?;
#[cfg(feature = "ai")]
if options.enable_ai {
writeln!(writer, "{}", atuin_ai::shell::BASH_INIT)?;
}
writeln!(writer, "}}") // end include guard
}
pub fn init_static(options: &StaticInitOptions<'_>) {
if let Err(e) = write_static_init(&mut io::stdout().lock(), options) {
// This function used to use `println!`, which panics on write failure with this same
// message. Using a locked `Stdout` object is faster, but `write!` returns an error rather
// than panicking, so we manually panic here to keep the same behavior.
panic!("failed printing to stdout: {e}");
}
}
View on GitHub (pinned to 900007c480)