{"record":{"id":"1fbd7f9030e3aa13","repo":"Hmbown/CodeWhale","slug":"program-exited-with-status","errorCode":null,"errorMessage":"{program} exited with {status}","messagePattern":"(.+?) exited with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":595,"sourceCode":"#[cfg(all(target_os = \"linux\", not(target_env = \"ohos\"), not(test)))]\nfn write_text_with_wlcopy_using_argv(program: &str, text: &str) -> Result<()> {\n    let mut child = Command::new(program)\n        .stdin(Stdio::piped())\n        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .spawn()\n        .map_err(|e| anyhow::anyhow!(\"Failed to run {program}: {e}\"))?;\n    if let Some(mut stdin) = child.stdin.take() {\n        stdin\n            .write_all(text.as_bytes())\n            .map_err(|e| anyhow::anyhow!(\"Failed to write to {program}: {e}\"))?;\n    }\n    // stdin is dropped here, closing the pipe so wl-copy flushes.\n    let status = child\n        .wait()\n        .map_err(|e| anyhow::anyhow!(\"Failed to wait on {program}: {e}\"))?;\n    if !status.success() {\n        bail!(\"{program} exited with {status}\");\n    }\n    Ok(())\n}\n\n#[cfg(not(test))]\nfn write_text_to_terminal_client(text: &str, in_tmux: bool) -> Result<()> {\n    if in_tmux {\n        return write_text_with_tmux(text);\n    }\n    write_text_with_osc52(text)\n}\n\n#[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.","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L577-L613","documentation":"wl-copy (Wayland clipboard writer) spawned and received the text on stdin, but the process exited nonzero, so the write is reported failed. The text is piped and stdin closed before waiting, so a nonzero exit usually means wl-copy could not reach the Wayland clipboard rather than a short write (those produce the 'Failed to write to ...' error instead).","triggerScenarios":"wl-copy present but no accessible compositor: WAYLAND_DISPLAY unset/stale, running over plain SSH, or the clipboard seat disappeared; some wl-clipboard versions also exit nonzero when stdin content is empty.","commonSituations":"Remote SSH into a desktop session without forwarding WAYLAND_DISPLAY; environment where wl-clipboard is installed on an X11 machine; tests invoking the argv path outside a compositor.","solutions":["Confirm wl-copy works by hand in the same environment: echo hi | wl-copy && wl-paste.","Export WAYLAND_DISPLAY and XDG_RUNTIME_DIR into Codewhale's environment, or run inside tmux so the load-buffer path is used.","On X11, install xclip/xsel so wl-copy is not selected as the write backend."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"fn wl_copy_likely_works() -> bool {\n    std::env::var_os(\"WAYLAND_DISPLAY\").is_some()\n        && std::env::var_os(\"XDG_RUNTIME_DIR\").is_some()\n}","typeGuard":null,"tryCatchPattern":"match write_text_with_wlcopy_using_argv(\"wl-copy\", text) {\n    Ok(()) => Ok(()),\n    Err(_) => write_text_with_osc52(text), // fall back to OSC 52 / tmux\n}","preventionTips":["Verify the backend by hand: echo hi | wl-copy && wl-paste in the same shell.","Keep a second clipboard path (tmux or OSC 52) enabled so failures degrade instead of erroring.","Remember empty text makes some wl-clipboard versions exit nonzero; skip empty writes."],"tags":["clipboard","wayland","wl-copy","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"}