{"record":{"id":"589ec43d80bf34ee","repo":"Hmbown/CodeWhale","slug":"failed-to-run-tmux-load-buffer-w-e","errorCode":null,"errorMessage":"Failed to run tmux load-buffer -w: {e}","messagePattern":"Failed to run tmux load-buffer -w: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":626,"sourceCode":"#[cfg(not(test))]\nfn write_text_with_tmux(text: &str) -> Result<()> {\n    write_text_with_tmux_using_argv(\"tmux\", &[], text)\n}\n\n/// Ask tmux to set both its paste buffer and the attached client's clipboard.\n/// Unlike DCS passthrough, `load-buffer -w` works with tmux's default\n/// `allow-passthrough off` policy and returns a non-zero status when tmux\n/// cannot honor the command.\n#[cfg(any(not(test), all(test, unix)))]\nfn write_text_with_tmux_using_argv(program: &str, prefix_args: &[&str], text: &str) -> Result<()> {\n    let mut child = Command::new(program)\n        .args(prefix_args)\n        .args([\"load-buffer\", \"-w\", \"-\"])\n        .stdin(Stdio::piped())\n        .stdout(Stdio::null())\n        .stderr(Stdio::piped())\n        .spawn()\n        .map_err(|e| anyhow::anyhow!(\"Failed to run tmux load-buffer -w: {e}\"))?;\n\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() {","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L608-L644","documentation":"Spawn of `tmux load-buffer -w -` failed while writing the clipboard through tmux (chosen when the TMUX env var is set). load-buffer -w sets both the tmux paste buffer and the attached client's clipboard and works with tmux's default allow-passthrough off. This spawn error means the tmux binary itself could not be executed - not that tmux refused the command (non-zero exit is a separate bail carrying stderr detail).","triggerScenarios":"in_tmux detection is true (TMUX env var set) but Command::new(\"tmux\").spawn() fails: tmux missing from PATH in the TUI's environment, not executable, or the env var leaked into a container/namespace where tmux does not exist.","commonSituations":"Containers inheriting TMUX from the host; NixOS/Guix-style nonstandard PATH; TUI launched from a service with minimal PATH; tmux uninstalled while session variables persisted.","solutions":["Run `command -v tmux` in the TUI's environment; fix PATH if it does not resolve","If you are not actually inside tmux, `unset TMUX` so the OSC 52 path is used","Install tmux or point the environment at its real location"],"exampleFix":"# before: TMUX leaked into a container\ndocker run -e TMUX=/tmp/tmux-1000/default … codewhale tui\n# -> Failed to run tmux load-buffer -w: No such file or directory\n\n# after: drop the leaked variable\ndocker run -e TMUX= … codewhale tui   # OSC 52 path instead","handlingStrategy":"validation","validationCode":"// Rust - verify tmux is actually reachable when TMUX is set\nfn tmux_transport_usable(in_tmux: bool) -> bool {\n    !in_tmux || which::which(\"tmux\").is_ok()\n}","typeGuard":null,"tryCatchPattern":"if tmux_transport_usable(ctx.in_tmux) { enqueue_terminal_write(text)?; } else { bail!(\"tmux transport unavailable\"); }","preventionTips":["Do not leak the TMUX variable into containers or cleaned environments","Ensure `command -v tmux` resolves in the environment the TUI launches from","Prefer OSC 52-capable terminals when tmux cannot be guaranteed"],"tags":["clipboard","tmux","spawn","path"],"backgroundTag":"process-spawn-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}