{"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":"warning","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":572,"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":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L554-L590","documentation":"wl-paste (the Wayland clipboard reader, run with --no-newline --type text/plain) was launched successfully but exited with a nonzero status, so its stdout is discarded and the read fails. The status in the message distinguishes this from launch failures ('Failed to run ...'). The function is used on Linux (non-OHOS) builds and in tests via explicit argv.","triggerScenarios":"wl-paste is installed but cannot reach a clipboard: no Wayland compositor (WAYLAND_DISPLAY unset or stale), no clipboard manager owns a selection, or the wl-clipboard version rejects the --type text/plain combination.","commonSituations":"SSH sessions into a Wayland desktop where WAYLAND_DISPLAY is not exported; X11-only sessions where wl-paste is installed as part of a distro bundle; wl-clipboard running with no compositor: it exits nonzero rather than returning empty.","solutions":["Verify a Wayland session and export WAYLAND_DISPLAY (and XDG_RUNTIME_DIR) into the Codewhale process.","If on X11, install xclip/xsel so the clipboard stack picks the matching backend instead of wl-paste.","Update wl-clipboard if the exit comes from option incompatibility; run wl-paste --no-newline --type text/plain manually to reproduce."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"fn wl_paste_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 read_text_with_wlpaste_using_argv(\"wl-paste\") {\n    Ok(text) => Ok(text),\n    Err(_) => read_text_with_osc52_fallback(), // try the next backend\n}","preventionTips":["Export WAYLAND_DISPLAY and XDG_RUNTIME_DIR into the app's environment on Wayland.","On X11, install xclip/xsel so the wl-paste path is never chosen.","Reproduce manually with wl-paste --no-newline --type text/plain before filing bugs."],"tags":["clipboard","wayland","wl-paste","external-tool","rust"],"backgroundTag":"clipboard-access-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}