{"record":{"id":"1f67294e320713e6","repo":"Hmbown/CodeWhale","slug":"program-exited-with","errorCode":null,"errorMessage":"{program} exited with {}","messagePattern":"(.+?) exited with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":727,"sourceCode":"}\n\n#[cfg(all(target_os = \"linux\", not(target_env = \"ohos\"), not(test)))]\nfn read_text_with_wlpaste() -> Result<String> {\n    read_text_with_wlpaste_using_argv(\"wl-paste\")\n}\n\n#[cfg(any(all(test, unix), all(target_os = \"linux\", not(target_env = \"ohos\"))))]\nfn read_text_with_wlpaste_using_argv(program: &str) -> Result<String> {\n    let output = Command::new(program)\n        .arg(\"--no-newline\")\n        .arg(\"--type\")\n        .arg(\"text/plain\")\n        .stdout(Stdio::piped())\n        .stderr(Stdio::null())\n        .output()\n        .map_err(|e| anyhow::anyhow!(\"Failed to run {program}: {e}\"))?;\n    if !output.status.success() {\n        bail!(\"{program} exited with {}\", output.status);\n    }\n    String::from_utf8(output.stdout).context(\"wl-paste returned non-UTF-8 text\")\n}\n\n#[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.","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/clipboard.rs#L709-L745","documentation":"`read_text_with_wlpaste_using_argv` runs an external Wayland clipboard reader (`wl-paste` or a configured helper) and requires it to exit successfully. When the program exits with a nonzero status, the function bails with this message instead of returning whatever partial stdout the program produced. It indicates the external clipboard helper itself failed, e.g. no Wayland clipboard manager is running.","triggerScenarios":"Calling `read_text_with_wlpaste` when the wl-paste helper binary exits nonzero — typically when no Wayland compositor/clipboard source is available, the Wayland display is unreachable, or the helper is misconfigured to a nonexistent wrapper script.","commonSituations":"Reading the clipboard over SSH into a machine without a Wayland session; running in a window manager with no clipboard daemon; `wl-paste` not installed for the current compositor; a custom helper program that returns an error status.","solutions":["Verify a Wayland session and clipboard manager are running (e.g. `wl-paste -n text/plain` manually returns data)","Check that the configured helper program exists and works; fall back to the default `wl-paste`","Ensure `WAYLAND_DISPLAY`/`XDG_RUNTIME_DIR` are set for the process environment","Handle the error and fall back to another clipboard backend (X11, OSC 52 read, internal buffer)"],"exampleFix":"// before\nlet text = clipboard.read_text_with_wlpaste()?;\n// after\nlet text = match clipboard.read_text_with_wlpaste() {\n    Ok(t) => t,\n    Err(e) => { eprintln!(\"clipboard read failed: {e}\"); String::new() }\n};","handlingStrategy":"try-catch","validationCode":"let probe = Command::new(\"wl-paste\").arg(\"--no-newline\").arg(\"text/plain\").status();\nif !probe.map(|s| s.success()).unwrap_or(false) {\n    // wl-paste unusable; choose another backend before calling read_text_with_wlpaste\n}","typeGuard":null,"tryCatchPattern":"let text = clipboard.read_text_with_wlpaste().unwrap_or_else(|e| {\n    log::warn!(\"wl-paste failed: {e}\");\n    String::new()\n});","preventionTips":["Verify a Wayland clipboard source exists before relying on wl-paste","Keep WAYLAND_DISPLAY/XDG_RUNTIME_DIR set in the process environment","Probe the helper once at startup and cache which backend works","Configure a known-good helper path rather than relying on defaults on headless boxes"],"tags":["clipboard","wayland","wl-paste","external-process"],"backgroundTag":"command-not-found","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"}