Hmbown/CodeWhale · error
Failed to run tmux load-buffer -w
Error message
Failed to run tmux load-buffer -w: {e} What it means
This error is raised when the TUI fails to spawn the `tmux load-buffer -w -` child process, which is how clipboard writes are pushed into tmux's paste buffer (and, via -w, the attached terminal's clipboard). The `e` in the message is the OS-level spawn error from `Command::spawn`, so the message reflects why the process could not be started at all — not why it exited later (spawn failures and nonzero exits are distinct branches in `write_text_with_tmux_using_argv`). It is thrown eagerly at spawn time so callers can fall back to OSC 52 or other clipboard transports.
Solutions
- Install tmux or ensure it is on PATH for the process running the TUI: run `command -v tmux` in the same shell, and fix PATH so the binary resolves.
- If tmux is installed but not executable for this user, fix permissions (`chmod +x $(command -v tmux)`) or reinstall the package.
- Check resource limits (`ulimit -u`) and reduce process usage if fork fails with EAGAIN.
- If tmux genuinely cannot be used, exit the tmux session so the code falls back to the OSC 52 clipboard path instead.
Example fix
// before: tmux missing from the process's PATH $ echo $TMUX set, but `command -v tmux` -> not found // after export PATH="$PATH:/usr/bin" # or install tmux: apt install tmux / nix-env -iA nixpkgs.tmux
Defensive patterns
Strategy: fallback
Validate before calling
fn tmux_available() -> bool {
std::process::Command::new("tmux")
.arg("-V")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false)
}
// call before requesting a tmux clipboard write:
let use_tmux = std::env::var_os("TMUX").is_some() && tmux_available(); Try / catch
match write_text_with_tmux(text) {
Ok(()) => {}
Err(e) if e.to_string().contains("Failed to run tmux load-buffer -w") => {
// spawn-level failure: fall back to OSC 52
write_text_with_osc52(text)?;
}
Err(e) => return Err(e),
} Prevention
- Check `std::env::var_os("TMUX")` and `tmux -V` availability before choosing the tmux transport.
- Keep tmux on PATH in minimal/container environments where the TUI runs.
- Fall back to OSC 52 clipboard output when the tmux binary cannot be spawned.
When it happens
Trigger: Calling `write_text_with_tmux` (or the test-visible `write_text_with_tmux_using_argv`) while `tmux` cannot be spawned: the binary is not on PATH (ENOENT), the user lacks execute permission (EACCES), or resource limits (fork/ENOMEM, EAGAIN too many processes) prevent `Command::new("tmux").args(["load-buffer","-w","-"]).spawn()` from succeeding.
Common situations: Running the TUI inside a tmux session where the tmux binary was removed or the PATH differs from the login shell (e.g. minimal systemd user PATH, Nix/venv shells missing /usr/bin); containers or chroots without tmux installed while $TMUX is set so the code still takes the tmux path; restricted environments with process-count limits (RLIMIT_NPROC) blocking fork.
Related errors
- Failed to run
- Failed to run
- MCP stdio spawn failed
- tmux load-buffer -w exited with
- tmux load-buffer -w exited with
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/589ec43d80bf34ee.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/clipboard.rs:781
#[cfg(not(test))]
fn write_text_with_tmux(text: &str) -> Result<()> {
write_text_with_tmux_using_argv("tmux", &[], text)
}
/// Ask tmux to set both its paste buffer and the attached client's clipboard.
/// Unlike DCS passthrough, `load-buffer -w` works with tmux's default
/// `allow-passthrough off` policy and returns a non-zero status when tmux
/// cannot honor the command.
#[cfg(any(not(test), all(test, unix)))]
fn write_text_with_tmux_using_argv(program: &str, prefix_args: &[&str], text: &str) -> Result<()> {
let mut child = Command::new(program)
.args(prefix_args)
.args(["load-buffer", "-w", "-"])
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::piped())
.spawn()
.map_err(|e| anyhow::anyhow!("Failed to run tmux load-buffer -w: {e}"))?;
let write_result = child
.stdin
.take()
.context("open tmux clipboard input")
.and_then(|mut stdin| {
stdin
.write_all(text.as_bytes())
.context("write tmux clipboard input")
});
let output = child
.wait_with_output()
.context("wait for tmux load-buffer -w")?;
write_result?;
if !output.status.success() {
let detail = String::from_utf8_lossy(&output.stderr);
let detail = detail.trim();
if detail.is_empty() {View on GitHub (pinned to 433685b202)