{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":725,"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":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/tui/clipboard.rs#L707-L743","documentation":"read_text_with_wlpaste_using_argv throws this when it fails to spawn the wl-paste process via Command::output(). The message wraps the raw spawn error (typically NotFound, PermissionDenied). It means the Wayland clipboard read could not even start the helper program, not that the paste failed afterwards.","triggerScenarios":"Calling read_text_with_wlpaste (or the test wl_paste_helper_reads_text_from_stdout) when the wl-paste binary does not exist on PATH, lacks execute permission, or the OS refuses the exec/fork (e.g. EAGAIN under heavy process limits).","commonSituations":"Running the TUI on X11 or macOS where wl-paste is not installed; a Wayland session without xdg-desktop-portal/wl-clipboard package; PATH stripped in a systemd service or cron context; wl-clipboard removed after a distro upgrade.","solutions":["Install the wl-clipboard package (wl-paste/wl-copy): e.g. apt install wl-clipboard / pacman -S wl-clipboard.","Verify wl-paste resolves on PATH: which wl-paste (fix PATH in the service environment if missing).","Confirm the session is Wayland (echo $WAYLAND_DISPLAY); on X11 use xclip/xsel instead.","Check execute permission on the wl-paste binary.","Handle the error by falling back to the library's other clipboard read backends."],"exampleFix":"// before\nlet text = read_text_with_wlpaste()?;\n// after\nlet text = read_text_with_wlpaste().or_else(|e| {\n    eprintln!(\"wl-paste unavailable ({e:#}); falling back\");\n    read_text_with_osc52()\n})?;","handlingStrategy":"fallback","validationCode":"use std::process::Command;\nfn wl_paste_available() -> bool {\n    Command::new(\"wl-paste\").arg(\"--no-newline\")\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .status().map(|s| s.success()).unwrap_or(false)\n}\nif !wl_paste_available() { /* use another read backend */ }","typeGuard":null,"tryCatchPattern":"match read_text_with_wlpaste() {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"Failed to run\") => {\n        eprintln!(\"wl-paste not runnable ({e:#}); falling back\");\n        read_text_with_osc52().unwrap_or_default()\n    }\n    Err(e) => { eprintln!(\"clipboard read failed: {e:#}\"); String::new() }\n}","preventionTips":["Install the wl-clipboard package on all Wayland deployment targets.","Smoke-test `which wl-paste` in CI/container images before shipping.","Fix PATH for services/IDE-launched processes so the helper resolves.","Fall back to X11 (xclip/xsel) or OSC52 backends when wl-paste is absent."],"tags":["clipboard","wayland","process-spawn","command-not-found"],"backgroundTag":"command-not-found","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}