xai-org/grok-build · error

{bin} exited with status {status}

Error message

{bin} exited with status {status}

What it means

A clipboard CLI write helper (e.g. xclip/xsel/wl-copy in write mode) spawned by the library exited with a non-zero status, so the write failed. The message includes the binary name and exit status; the tool's stderr was not captured on this path.

Source

Thrown at crates/codegen/xai-grok-shared/src/clipboard.rs:1813

        // Spooled stdin (`spool_for_stdin`), not a pipe: clipboard tools
        // (wl-copy/xclip) daemonize and read the payload after forking, racing
        // a pipe write and possibly leaving the selection empty; the daemon
        // keeps its fd to the unlinked temp file.
        let stdin = super::spool_for_stdin(data)?;

        let mut cmd = Command::new(bin);
        cmd.args(args)
            .stdin(Stdio::from(stdin))
            .stdout(Stdio::null())
            .stderr(Stdio::null());
        xai_grok_tools::util::detach_std_command(&mut cmd);
        #[allow(clippy::disallowed_methods)] // short-lived clipboard helper, waited on below
        let mut child = cmd
            .spawn()
            .map_err(|e| anyhow::anyhow!("failed to spawn {bin}: {e}"))?;
        let status = super::wait_with_deadline(&mut child, CLI_WRITE_WAIT)?;
        if !status.success() {
            anyhow::bail!("{bin} exited with status {status}");
        }
        Ok(())
    }

    /// Run a CLI tool and capture its stdout, bounded by `deadline`
    /// (`CLI_PROBE_WAIT` for read-backs, `CLI_READ_WAIT` for content reads).
    #[cfg(target_os = "linux")]
    fn run_capture_out_with_status(
        argv: &[&str],
        deadline: std::time::Duration,
    ) -> anyhow::Result<(std::process::ExitStatus, Vec<u8>)> {
        let (bin, args) = argv.split_first().expect("argv non-empty");
        let mut cmd = Command::new(bin);
        cmd.args(args)
            .stdin(Stdio::null())
            .stdout(Stdio::piped())
            .stderr(Stdio::null());
        xai_grok_tools::util::detach_std_command(&mut cmd);

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Run the failing tool manually (e.g. `echo test | wl-copy` or `xclip -selection clipboard`) to see its real error
  2. Ensure DISPLAY (X11) or WAYLAND_DISPLAY (Wayland) is set and matches the session type
  3. Install the tool matching your session: xclip/xsel for X11, wl-clipboard for Wayland
  4. Try another clipboard leg — set_text falls back across multiple backends
Defensive patterns

Strategy: retry

Validate before calling

fn write_tool_available(bin: &str) -> bool {
    which::which(bin).is_ok()
}
// e.g. assert!(write_tool_available("wl-copy") || write_tool_available("xclip"));

Try / catch

match clipboard::set_text(&text) {
    Err(e) if e.to_string().contains("exited with status") => {
        eprintln!("clipboard write failed: {e}; retrying once");
        std::thread::sleep(std::time::Duration::from_millis(200));
        clipboard::set_text(&text)
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling set_text/set_text_with_outcome on Linux where the chosen CLI tool starts but exits non-zero — e.g. xclip cannot open the X display, wl-copy has no Wayland seat, or the tool aborts on invalid input.

Common situations: Wayland/X11 mismatch (running X11 tool under pure Wayland or vice versa), missing DISPLAY/WAYLAND_DISPLAY, misconfigured or crashed clipboard daemons.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/5290c6d2e34ccb4c. Report an issue: GitHub.