{"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":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":802,"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":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/clipboard.rs#L784-L820","documentation":"The detailed variant of the tmux clipboard failure: when `tmux load-buffer -w` exits nonzero and stderr contains text, that trimmed stderr is appended to the message. This gives the actual tmux diagnostic (e.g. why `-w` failed or why the buffer could not be created) alongside the exit status.","triggerScenarios":"Calling `write_text_with_tmux` when tmux exits nonzero AND writes a diagnostic to stderr — e.g. `load-buffer -w` failing to set the clipboard of the attached client, passthrough issues, or an invalid socket/session state.","commonSituations":"tmux 3.2+ but `set-clipboard` disabled server-side; `allow-passthrough` off with prefix passthrough expectations; permission denied on the tmux socket; reading the message to diagnose why the attached terminal did not receive the copy.","solutions":["Read the stderr detail in the message and fix the named tmux condition (e.g. enable `set-clipboard on` or `allow-passthrough` in `~/.tmux.conf`)","Upgrade tmux if the detail indicates `-w` is unknown","Verify the TMUX socket/session is healthy by running the load-buffer command manually","Fall back to a system clipboard helper when tmux refuses the write"],"exampleFix":"// before\nmatch err.to_string() { ... } // opaque\n// after\n// message now contains the tmux stderr, e.g.:\n// \"tmux load-buffer -w exited with exit status: 1: clipboard unavailable\" — fix per detail","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match clipboard.write_text_with_tmux(text) {\n    Err(e) => {\n        let msg = e.to_string();\n        if let Some(detail) = msg.split_once(\": \").map(|(_, d)| d) {\n            log::error!(\"tmux diagnostic: {detail}\"); // act on the tmux stderr\n        }\n        clipboard.write_text(text).ok();\n    }\n    Ok(()) => {},\n}","preventionTips":["Read and act on the tmux stderr embedded in the message instead of retrying blindly","Enable `set-clipboard` / `allow-passthrough` in ~/.tmux.conf as the message's detail suggests","Keep tmux current — many stderr diagnostics indicate version-specific `-w` issues","Test the tmux copy path after changing tmux config"],"tags":["clipboard","tmux","external-process","stderr"],"backgroundTag":"git-command-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}