Hmbown/CodeWhale · warning

tmux load-buffer -w exited with {}: {detail}

Error message

tmux load-buffer -w exited with {}: {detail}

What it means

Same tmux load-buffer -w failure as the empty-stderr variant, but here tmux printed a reason on stderr and it is appended to the message (e.g. 'lost server', 'no such session', 'error adding buffer'). The detail is the authoritative cause; the status code merely confirms nonzero exit.

Source

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

        .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
        .write_all(sequence.as_bytes())
        .context("write OSC 52 clipboard sequence")?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Read the appended detail: 'lost server'/'no such session' means reattach or retry after the server is back; 'error adding buffer' means raise buffer-limit or prune buffers.
  2. Retry the copy once the tmux session is stable; this failure class is almost always transient session state.
  3. Set set-option -g buffer-limit to a comfortable value (default 50) if clipboard churn is high.

Example fix

# before (~/.tmux.conf)
set-option -g buffer-limit 2   # 'error adding buffer' under churn

# after
set-option -g buffer-limit 50
Defensive patterns

Strategy: fallback

Try / catch

match write_text_with_tmux(text) {
    Err(e) if e.to_string().contains("lost server") || e.to_string().contains("no such session") => {
        write_text_with_osc52(text) // session died: skip tmux entirely
    }
    Err(e) if e.to_string().contains("error adding buffer") => {
        Command::new("tmux").args(["delete-buffer", "-b", "0"]).status().ok();
        write_text_with_tmux(text) // prune and retry once
    }
    other => other,
}

Prevention

When it happens

Trigger: Copying while the target tmux session/pane is being killed ('lost server', 'no such session'); permissions on the tmux socket; 'error adding buffer' when the tmux buffer limit (buffer-limit) is exhausted and old buffers cannot be freed.

Common situations: Scripted session teardown racing a copy; buffer-limit lowered in .tmux.conf with heavy clipboard churn; shared tmux sockets between users with mismatched permissions.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/97727b825ee9d855. Report an issue: GitHub.