{"record":{"id":"ebc3e1b93bf2cdf6","repo":"Hmbown/CodeWhale","slug":"failed-to-run-program-e","errorCode":null,"errorMessage":"Failed to run {program}: {e}","messagePattern":"Failed to run (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":570,"sourceCode":"fn write_text_with_wlcopy(text: &str) -> Result<()> {\n    write_text_with_wlcopy_using_argv(\"wl-copy\", text)\n}\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}\"))?;","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L552-L588","documentation":"read_text_with_wlpaste_using_argv failed to spawn `wl-paste --no-newline --type text/plain`, the first paste attempt on Linux. The OS error is appended and almost always means the wl-clipboard package is missing or unreachable in PATH. ClipboardHandler::read swallows this and falls back to arboard, so it becomes user-visible only when every read path fails.","triggerScenarios":"Command::new(\"wl-paste\").output() returns Err: wl-clipboard not installed, PATH lacking the binary's directory, file present but not executable, or process/resource limits blocking spawn.","commonSituations":"Fresh distro without wl-clipboard; X11-only sessions; TUI launched from systemd/launcher with minimal PATH; container images.","solutions":["Install wl-clipboard: `apt install wl-clipboard` / `dnf install wl-clipboard` / `pacman -S wl-clipboard`","Verify `wl-paste --no-newline --type text/plain` succeeds in the same shell the TUI launches from","Ensure PATH includes /usr/bin; restart the TUI after installing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust - check wl-paste presence before attempting a Wayland read\nfn wlpaste_available() -> bool {\n    which::which(\"wl-paste\").is_ok()\n        && std::env::var_os(\"WAYLAND_DISPLAY\").is_some_and(|v| !v.is_empty())\n}","typeGuard":null,"tryCatchPattern":"if wlpaste_available() { /* try wl-paste first */ } else { skip_to_arboard_fallback(); }","preventionTips":["Install wl-clipboard as part of the workstation setup on Wayland Linux","Keep the TUI's PATH identical to the interactive shell","Do not assume wl-paste exists on X11-only or headless systems"],"tags":["clipboard","wl-clipboard","wayland","paste","spawn"],"backgroundTag":"process-spawn-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}