{"record":{"id":"b09b141bc46f3cf3","repo":"xai-org/grok-build","slug":"failed-to-run-osascript-e","errorCode":null,"errorMessage":"failed to run osascript: {e}","messagePattern":"failed to run osascript: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":1181,"sourceCode":"        {\n            Some(\"jpg\" | \"jpeg\") => \"JPEG\",\n            Some(\"tiff\" | \"tif\") => \"TIFF\",\n            _ => \"PNGf\",\n        };\n        let path_str = path.display().to_string().replace('\"', \"\\\\\\\"\");\n        let script = format!(\n            \"set the clipboard to (read (POSIX file \\\"{path_str}\\\") as \\u{00AB}class {class}\\u{00BB})\"\n        );\n        let mut cmd = Command::new(\"osascript\");\n        cmd.arg(\"-e\")\n            .arg(&script)\n            .stdin(Stdio::null())\n            .stdout(Stdio::null())\n            .stderr(Stdio::piped());\n        xai_grok_tools::util::detach_std_command(&mut cmd);\n        let output = cmd\n            .output()\n            .map_err(|e| anyhow::anyhow!(\"failed to run osascript: {e}\"))?;\n\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            anyhow::bail!(\"osascript failed: {stderr}\");\n        }\n        Ok(())\n    }\n}\n\n// ---------------------------------------------------------------------------\n// Linux / Windows: arboard with CLI-tool fallback on Linux\n// ---------------------------------------------------------------------------\n#[cfg(not(target_os = \"macos\"))]\nmod platform {\n    use super::ImageData;\n    use std::process::{Command, Stdio};\n\n    /// No subprocess-free pasteboard probe exists off-macOS.","sourceCodeStart":1163,"sourceCodeEnd":1199,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L1163-L1199","documentation":"set_image_file (crates/codegen/xai-grok-shared/src/clipboard.rs:1181) copies an image file to the clipboard by running an osascript; this error wraps the io error when osascript itself cannot be launched. Script-level failures instead surface as 'osascript failed: {stderr}'.","triggerScenarios":"set_image_file called where osascript is absent (Linux/Windows), not executable, or PATH excludes /usr/bin.","commonSituations":"Linux dev machines running macOS clipboard paths; containers without macOS scripting tools; hardened environments stripping PATH.","solutions":["Verify osascript exists: `which osascript`; only run this path on macOS.","Correct the PATH for the invoking process.","Use an alternative image-copy backend (arboard image set) off-macOS."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"let osascript_ok = std::process::Command::new(\"osascript\").arg(\"-e\").arg(\"return 1\").output().is_ok();","typeGuard":null,"tryCatchPattern":"match set_image_file(path) {\n    Err(e) if e.to_string().contains(\"failed to run osascript\") => fallback_image_copy(path),\n    other => other,\n}","preventionTips":["Run the osascript path only on macOS.","Check osascript availability before image copy.","Maintain a non-osascript image-copy fallback."],"tags":["clipboard","macos","osascript","process-spawn"],"backgroundTag":"command-spawn-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}