{"record":{"id":"c29ae73c88d08450","repo":"Hmbown/CodeWhale","slug":"tmux-load-buffer-w-exited-with","errorCode":null,"errorMessage":"tmux load-buffer -w exited with {}","messagePattern":"tmux load-buffer -w exited with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":800,"sourceCode":"\n    let write_result = child\n        .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","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/clipboard.rs#L782-L818","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade tmux to >= 3.2 so `load-buffer -w` is supported","Confirm you are actually inside tmux (`$TMUX` set; `tmux display-message` works)","Run `printf x | tmux load-buffer -w` manually to reproduce the exit status and socket state","Fall back to a non-tmux clipboard path (wl-copy/OSC 52) when the tmux write fails"],"exampleFix":"// before\nclipboard.write_text_with_tmux(text)?;\n// after\nif let Err(e) = clipboard.write_text_with_tmux(text) {\n    eprintln!(\"tmux clipboard failed: {e}\");\n    clipboard.write_text(text)?; // non-tmux fallback\n}","handlingStrategy":"fallback","validationCode":"let tmux_ok = std::env::var_os(\"TMUX\").is_some()\n    && Command::new(\"tmux\").arg(\"display-message\").arg(\"-p\").arg(\"#S\")\n        .status().map(|s| s.success()).unwrap_or(false);","typeGuard":null,"tryCatchPattern":"match clipboard.write_text_with_tmux(text) {\n    Err(e) if e.to_string().contains(\"tmux load-buffer -w exited\") => {\n        clipboard.write_text(text).ok(); // non-tmux fallback\n    }\n    other => other?,\n}","preventionTips":["Require tmux >= 3.2 for `load-buffer -w` support","Confirm $TMUX is set and the tmux server is reachable before using this path","Probe `printf x | tmux load-buffer -w` at startup to validate the path","Keep a non-tmux clipboard fallback wired in"],"tags":["clipboard","tmux","external-process","exit-status"],"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"}