{"record":{"id":"97727b825ee9d855","repo":"Hmbown/CodeWhale","slug":"tmux-load-buffer-w-exited-with-detail","errorCode":null,"errorMessage":"tmux load-buffer -w exited with {}: {detail}","messagePattern":"tmux load-buffer -w exited with (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":647,"sourceCode":"        .stdin\n        .take()\n        .context(\"open tmux clipboard input\")\n        .and_then(|mut stdin| {\n            stdin\n                .write_all(text.as_bytes())\n                .context(\"write tmux clipboard input\")\n        });\n    let output = child\n        .wait_with_output()\n        .context(\"wait for tmux load-buffer -w\")?;\n    write_result?;\n    if !output.status.success() {\n        let detail = String::from_utf8_lossy(&output.stderr);\n        let detail = detail.trim();\n        if detail.is_empty() {\n            bail!(\"tmux load-buffer -w exited with {}\", output.status);\n        }\n        bail!(\n            \"tmux load-buffer -w exited with {}: {detail}\",\n            output.status\n        );\n    }\n    Ok(())\n}\n\n#[cfg(not(test))]\nfn write_text_with_osc52(text: &str) -> Result<()> {\n    let mut stdout = io::stdout();\n    if !stdout.is_terminal() {\n        bail!(\"OSC 52 clipboard fallback requires a terminal\");\n    }\n\n    let sequence = osc52_sequence(text)?;\n    stdout\n        .write_all(sequence.as_bytes())\n        .context(\"write OSC 52 clipboard sequence\")?;","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L629-L665","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scripted session teardown racing a copy; buffer-limit lowered in .tmux.conf with heavy clipboard churn; shared tmux sockets between users with mismatched permissions.","solutions":["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.","Retry the copy once the tmux session is stable; this failure class is almost always transient session state.","Set set-option -g buffer-limit to a comfortable value (default 50) if clipboard churn is high."],"exampleFix":"# before (~/.tmux.conf)\nset-option -g buffer-limit 2   # 'error adding buffer' under churn\n\n# after\nset-option -g buffer-limit 50","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match write_text_with_tmux(text) {\n    Err(e) if e.to_string().contains(\"lost server\") || e.to_string().contains(\"no such session\") => {\n        write_text_with_osc52(text) // session died: skip tmux entirely\n    }\n    Err(e) if e.to_string().contains(\"error adding buffer\") => {\n        Command::new(\"tmux\").args([\"delete-buffer\", \"-b\", \"0\"]).status().ok();\n        write_text_with_tmux(text) // prune and retry once\n    }\n    other => other,\n}","preventionTips":["Read the stderr detail appended to the message; it names the real tmux failure.","Raise buffer-limit in .tmux.conf if clipboard churn hits 'error adding buffer'.","Retry copies after session churn (reattach, server restart) instead of treating them as permanent."],"tags":["clipboard","tmux","external-tool","rust"],"backgroundTag":"clipboard-write-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}