{"record":{"id":"709089c7d8e0143e","repo":"xai-org/grok-build","slug":"failed-to-run-bin-e","errorCode":null,"errorMessage":"failed to run {bin}: {e}","messagePattern":"failed to run (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":1835,"sourceCode":"\n    /// Run a CLI tool and capture its stdout, bounded by `deadline`\n    /// (`CLI_PROBE_WAIT` for read-backs, `CLI_READ_WAIT` for content reads).\n    #[cfg(target_os = \"linux\")]\n    fn run_capture_out_with_status(\n        argv: &[&str],\n        deadline: std::time::Duration,\n    ) -> anyhow::Result<(std::process::ExitStatus, Vec<u8>)> {\n        let (bin, args) = argv.split_first().expect(\"argv non-empty\");\n        let mut cmd = Command::new(bin);\n        cmd.args(args)\n            .stdin(Stdio::null())\n            .stdout(Stdio::piped())\n            .stderr(Stdio::null());\n        xai_grok_tools::util::detach_std_command(&mut cmd);\n        #[allow(clippy::disallowed_methods)] // short-lived clipboard helper, waited on below\n        let mut child = cmd\n            .spawn()\n            .map_err(|e| anyhow::anyhow!(\"failed to run {bin}: {e}\"))?;\n        // Drain stdout on a worker so the deadline wait can kill a hung tool\n        // without deadlocking on a full pipe; the kill EOFs the pipe and the\n        // reader exits on its own.\n        let mut stdout = child.stdout.take().expect(\"stdout piped\");\n        let reader = std::thread::spawn(move || {\n            use std::io::Read;\n            let mut buf = Vec::new();\n            let _ = stdout.read_to_end(&mut buf);\n            buf\n        });\n        let status = super::wait_with_deadline(&mut child, deadline)?;\n        let stdout = reader.join().unwrap_or_default();\n        Ok((status, stdout))\n    }\n\n    /// Capture CLI stdout. Non-zero exit → empty bytes (typed MIME absent), not Err.\n    /// Spawn/timeout failures still return Err. Prefer this over\n    /// [`run_capture_out_checked`] for content reads where a missing type is","sourceCodeStart":1817,"sourceCodeEnd":1853,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L1817-L1853","documentation":"The CLI clipboard read helper at crates/codegen/xai-grok-shared/src/clipboard.rs:1835 spawns a read tool (e.g. wl-paste/xclip) with piped stdout and maps a spawn failure to this error. stdout is drained on a worker thread so a hung tool can be killed at the deadline; a non-zero exit is reported separately.","triggerScenarios":"Reading the clipboard via the CLI path when the binary is missing from PATH, not executable, or the exec fails — same conditions as the write-side spawn error but on the read path.","commonSituations":"Fresh Linux installs without xclip/wl-paste; containers; running the X11 tool under Wayland or vice versa.","solutions":["Install the matching reader (`wl-clipboard` or `xclip`) and verify with `which <bin>`.","Select the binary based on the active display server.","Correct PATH in the invoking environment.","Use arboard-based reads as a fallback."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn pick_read_bin() -> Option<&'static str> {\n    let wayland = std::env::var_os(\"WAYLAND_DISPLAY\").is_some();\n    let (preferred, alt) = if wayland { (\"wl-paste\", \"xclip\") } else { (\"xclip\", \"wl-paste\") };\n    [preferred, alt].into_iter().find(|b| which(b).is_some())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the reader binary matching your display server is installed.","Probe read-tool availability before relying on CLI clipboard reads.","Fall back to arboard reads when no CLI tool is present."],"tags":["clipboard","linux","process-spawn","cli-tools"],"backgroundTag":"command-spawn-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}