xai-org/grok-build · error
{label} exited with {}: {}
Error message
{label} exited with {}: {} What it means
`checked_command_stdout` wraps external clipboard helper commands (osascript, pbpaste, etc.) and bails when the child process exits non-zero, embedding the exit status and trimmed stderr in the message. It surfaces the underlying tool's own failure text to the caller.
Source
Thrown at crates/codegen/xai-grok-shared/src/clipboard.rs:784
// regions cannot overlap.
unsafe {
std::ptr::copy_nonoverlapping(bytes_ptr as *const u8, buf.as_mut_ptr(), len);
}
Some(super::ImageData {
data: buf,
mime_type: mime.to_owned(),
})
})
}
pub(super) fn checked_command_stdout(
label: &str,
output: std::io::Result<std::process::Output>,
) -> anyhow::Result<Vec<u8>> {
let output = output.map_err(|error| anyhow::anyhow!("failed to run {label}: {error}"))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
anyhow::bail!("{label} exited with {}: {}", output.status, stderr.trim());
}
Ok(output.stdout)
}
fn attachments_probe_temp_paths() -> (std::path::PathBuf, std::path::PathBuf, std::path::PathBuf)
{
let temp_dir = std::env::temp_dir();
(
temp_dir.join("grok-clipboard-probe.png"),
temp_dir.join("grok-clipboard-probe.tiff"),
temp_dir.join("grok-clipboard-probe.jpg"),
)
}
fn read_clipboard_image_from_class(
class: &str,
path_png: &std::path::Path,
path_tiff: &std::path::Path,View on GitHub (pinned to bc7f02eddd)
Solutions
- Read the stderr portion of the message to see the helper's own diagnostic and fix that root cause
- On macOS grant the terminal app Accessibility/Automation permission to control clipboard (System Settings > Privacy & Security)
- Verify the helper binary exists and works by running it manually with the same arguments
- Retry the clipboard operation — transient pasteboard contention can cause one-shot failures
Defensive patterns
Strategy: retry
Validate before calling
// Verify the helper works before relying on it (macOS example)
fn helper_ok(bin: &str) -> bool {
std::process::Command::new(bin).arg("-e").arg("return 0").output()
.map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match clipboard::get_text() {
Ok(t) => use_text(&t),
Err(e) if e.to_string().contains("exited with") => {
eprintln!("clipboard helper failed: {e}");
retry_with_backoff(3, || clipboard::get_text());
}
Err(e) => return Err(e.into()),
} Prevention
- On macOS, pre-grant terminal Automation permissions so osascript/pbpaste never fail on TCC
- Log the exit status + stderr portion of the message for the root cause
- Retry once or twice — pasteboard contention can be transient
- Run helper binaries once at startup as a health check
When it happens
Trigger: Calling set_text/get_text/get_image or the macOS attachments osascript flow when the spawned helper exits non-zero — e.g. osascript blocked by TCC permissions, pbpaste with no pasteboard access, or the binary missing/segfaulting.
Common situations: macOS Terminal/IDE lacking Automation permissions for clipboard Apple events; sandboxed or SSH sessions where the helper cannot reach the pasteboard; a distro where the installed clipboard tool prints an error on stderr.
Related errors
- pbcopy exited with status {status}
- osascript failed: {stderr}
- {bin} exited with status {status}
- failed to run {label}: {error}
- failed to spawn pbcopy: {e}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/8a256f301400e81f.
Report an issue: GitHub.