{"record":{"id":"f06be376e31d6c58","repo":"xai-org/grok-build","slug":"failed-to-run-label-error","errorCode":null,"errorMessage":"failed to run {label}: {error}","messagePattern":"failed to run (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":781,"sourceCode":"            let mut buf = vec![0u8; len];\n            // SAFETY: source is valid for `len` reads (NSData contract),\n            // destination is a fresh Vec of exactly `len` bytes, and the\n            // regions cannot overlap.\n            unsafe {\n                std::ptr::copy_nonoverlapping(bytes_ptr as *const u8, buf.as_mut_ptr(), len);\n            }\n            Some(super::ImageData {\n                data: buf,\n                mime_type: mime.to_owned(),\n            })\n        })\n    }\n\n    pub(super) fn checked_command_stdout(\n        label: &str,\n        output: std::io::Result<std::process::Output>,\n    ) -> anyhow::Result<Vec<u8>> {\n        let output = output.map_err(|error| anyhow::anyhow!(\"failed to run {label}: {error}\"))?;\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            anyhow::bail!(\"{label} exited with {}: {}\", output.status, stderr.trim());\n        }\n        Ok(output.stdout)\n    }\n\n    fn attachments_probe_temp_paths() -> (std::path::PathBuf, std::path::PathBuf, std::path::PathBuf)\n    {\n        let temp_dir = std::env::temp_dir();\n        (\n            temp_dir.join(\"grok-clipboard-probe.png\"),\n            temp_dir.join(\"grok-clipboard-probe.tiff\"),\n            temp_dir.join(\"grok-clipboard-probe.jpg\"),\n        )\n    }\n\n    fn read_clipboard_image_from_class(","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L763-L799","documentation":"checked_command_stdout in crates/codegen/xai-grok-shared/src/clipboard.rs:781 wraps the std::io::Result of running a macOS clipboard command (pbpaste/osascript) and fails with this message when the process could not be launched at all. A non-zero exit is reported separately, so this error specifically means spawn/exec failed (typically binary not found).","triggerScenarios":"get_text, get_image, or run_attachments_osascript invoking a command whose binary is missing from PATH or not executable — e.g. pbpaste/osascript absent on Linux.","commonSituations":"Running macOS-targeted clipboard code on Linux/CI containers; minimal Docker images without macOS system tools; stripped PATH in systemd/IDE-launched processes.","solutions":["Verify the tool (pbpaste/osascript/pbcopy) exists: `which <tool>`; install it or run on macOS.","Fix PATH for the environment running the process so the system binary dir is included.","Fall back to an alternate clipboard backend (e.g. arboard) when the OS tool is unavailable."],"exampleFix":"// before\nlet bytes = checked_command_stdout(\"pbpaste\", Command::new(\"pbpaste\").output())?;\n// after\nmatch checked_command_stdout(\"pbpaste\", Command::new(\"pbpaste\").output()) {\n    Ok(bytes) => bytes,\n    Err(e) => return fallback_backend().map_err(|_| e),\n}","handlingStrategy":"fallback","validationCode":"fn tool_available(bin: &str) -> bool {\n    std::process::Command::new(bin).arg(\"--help\").output().is_ok()\n}","typeGuard":null,"tryCatchPattern":"match get_text() {\n    Err(e) if e.to_string().starts_with(\"failed to run \") => fallback_backend(),\n    other => other,\n}","preventionTips":["Probe for pbpaste/osascript availability before the macOS code path.","Keep /usr/bin on PATH in daemons and CI.","Gate clipboard calls on the target OS."],"tags":["clipboard","macos","process-spawn"],"backgroundTag":"command-spawn-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}