Hmbown/CodeWhale · error

tmux load-buffer -w exited with

Error message

tmux load-buffer -w exited with {}

What it means

`write_text_with_tmux_using_argv` pipes the selection into `tmux load-buffer -w`, which copies to both tmux's buffer and the attached client's clipboard. When tmux exits nonzero but prints nothing on stderr, this bare message is raised with only the exit status. It means tmux rejected the command with no diagnostic output.

Solutions

  1. Upgrade tmux to >= 3.2 so `load-buffer -w` is supported
  2. Confirm you are actually inside tmux (`$TMUX` set; `tmux display-message` works)
  3. Run `printf x | tmux load-buffer -w` manually to reproduce the exit status and socket state
  4. Fall back to a non-tmux clipboard path (wl-copy/OSC 52) when the tmux write fails

Example fix

// before
clipboard.write_text_with_tmux(text)?;
// after
if let Err(e) = clipboard.write_text_with_tmux(text) {
    eprintln!("tmux clipboard failed: {e}");
    clipboard.write_text(text)?; // non-tmux fallback
}
Defensive patterns

Strategy: fallback

Validate before calling

let tmux_ok = std::env::var_os("TMUX").is_some()
    && Command::new("tmux").arg("display-message").arg("-p").arg("#S")
        .status().map(|s| s.success()).unwrap_or(false);

Try / catch

match clipboard.write_text_with_tmux(text) {
    Err(e) if e.to_string().contains("tmux load-buffer -w exited") => {
        clipboard.write_text(text).ok(); // non-tmux fallback
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `write_text_with_tmux` when the `tmux load-buffer -w` child process exits with a nonzero status and its stderr is empty — e.g. tmux server not running and socket creation fails, or `-w` unsupported by an old tmux and no message is emitted.

Common situations: Running outside a real tmux session but with `in_tmux` misdetecting; very old tmux versions lacking `-w` (added in tmux 3.2); TMUX socket permission problems where tmux exits silently.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/c29ae73c88d08450. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tui/clipboard.rs:800

    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() {
            bail!("tmux load-buffer -w exited with {}", output.status);
        }
        bail!(
            "tmux load-buffer -w exited with {}: {detail}",
            output.status
        );
    }
    Ok(())
}

#[cfg(not(test))]
fn write_text_with_osc52(text: &str) -> Result<()> {
    let mut stdout = io::stdout();
    if !stdout.is_terminal() {
        bail!("OSC 52 clipboard fallback requires a terminal");
    }

    let sequence = osc52_sequence(text)?;
    stdout

View on GitHub (pinned to 73e0f67d83)