{"record":{"id":"09af556537e32c67","repo":"xai-org/grok-build","slug":"failed-to-spawn-bin-e","errorCode":null,"errorMessage":"failed to spawn {bin}: {e}","messagePattern":"failed to spawn (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":1810,"sourceCode":"    fn run_pipe_in(argv: &[&str], data: &[u8]) -> anyhow::Result<()> {\n        let (bin, args) = argv.split_first().expect(\"argv non-empty\");\n\n        // Spooled stdin (`spool_for_stdin`), not a pipe: clipboard tools\n        // (wl-copy/xclip) daemonize and read the payload after forking, racing\n        // a pipe write and possibly leaving the selection empty; the daemon\n        // keeps its fd to the unlinked temp file.\n        let stdin = super::spool_for_stdin(data)?;\n\n        let mut cmd = Command::new(bin);\n        cmd.args(args)\n            .stdin(Stdio::from(stdin))\n            .stdout(Stdio::null())\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 spawn {bin}: {e}\"))?;\n        let status = super::wait_with_deadline(&mut child, CLI_WRITE_WAIT)?;\n        if !status.success() {\n            anyhow::bail!(\"{bin} exited with status {status}\");\n        }\n        Ok(())\n    }\n\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())","sourceCodeStart":1792,"sourceCodeEnd":1828,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L1792-L1828","documentation":"The CLI clipboard write helper at crates/codegen/xai-grok-shared/src/clipboard.rs:1810 spawns an external write tool (bin, e.g. wl-copy or xclip) and maps a spawn failure to this error. A later non-zero exit is reported separately as '{bin} exited with status'. This is purely a launch failure.","triggerScenarios":"Writing the clipboard on Linux with the chosen binary (wl-copy/xclip/xsel) not installed, not on PATH, or not executable; the wait is bounded by wait_with_deadline(CLI_WRITE_WAIT).","commonSituations":"Wayland users lacking wl-copy, X11 users lacking xclip; minimal Docker images; mismatch between session type and installed tool (running wl-copy under X11-only envs).","solutions":["Install the appropriate tool: `wl-clipboard` (Wayland) or `xclip`/`xsel` (X11); confirm with `which <bin>`.","Pick the backend matching the session: WAYLAND_DISPLAY vs DISPLAY.","Fix PATH for the invoking process.","Fall back to the arboard backend when no CLI tool exists."],"exampleFix":"// before\nrun_write_bin(\"wl-copy\", input)?;\n// after\nlet bin = if std::env::var_os(\"WAYLAND_DISPLAY\").is_some() { \"wl-copy\" } else { \"xclip\" };\nif which(bin).is_some() { run_write_bin(bin, input)?; } else { arboard_set_text(&input)?; }","handlingStrategy":"validation","validationCode":"fn pick_write_bin() -> Option<&'static str> {\n    let wayland = std::env::var_os(\"WAYLAND_DISPLAY\").is_some();\n    let (preferred, alt) = if wayland { (\"wl-copy\", \"xclip\") } else { (\"xclip\", \"wl-copy\") };\n    [preferred, alt].into_iter().find(|b| which(b).is_some())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install wl-clipboard (Wayland) or xclip/xsel (X11) in target environments.","Match the tool to the session type (WAYLAND_DISPLAY vs DISPLAY).","Verify tool presence at app startup, not at first write."],"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"}