xai-org/grok-build · error

no clipboard backend available

Error message

no clipboard backend available

What it means

`set_text` returns this when every configured clipboard backend (arboard, Wayland, and platform CLI tools like pbcopy/xclip) failed to write, so `any_ok` is false and no mechanism reported success. It means the process has no working clipboard path at all in the current environment.

Source

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

    /// arboard write landed; a focus-free authoritative write additionally
    /// requires `arboard_ok`. Always false on macOS/Windows/X11.
    pub data_control: bool,
    /// True when at least one leg succeeded.
    pub any_ok: bool,
}

/// Write text and return per-leg outcomes for telemetry callers.
pub fn set_text_with_outcome(text: &str) -> NativeWriteOutcome {
    platform::set_text_with_outcome(text)
}

/// Write text to the system clipboard.
pub fn set_text(text: &str) -> anyhow::Result<()> {
    let outcome = platform::set_text_with_outcome(text);
    if outcome.any_ok {
        Ok(())
    } else {
        anyhow::bail!("no clipboard backend available")
    }
}

/// Copy an image file to the system clipboard.
///
/// On macOS, uses `osascript` to set the pasteboard from a file path.
/// On Linux, uses `wl-copy` or `xclip` if available.
/// On Windows, returns an error (not yet supported).
pub fn set_image_file(path: &std::path::Path) -> anyhow::Result<()> {
    platform::set_image_file(path)
}

/// The clipboard tool used for native writes on the current platform.
///
/// Returns `"pbcopy"` on macOS, `"arboard"` on Windows, and the probed CLI
/// tool name on Linux (or `"arboard"` if no CLI tool was found).
pub fn native_tool_name() -> &'static str {
    #[cfg(target_os = "macos")]

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Install a clipboard CLI tool (xclip or xsel for X11, wl-clipboard for Wayland; pbcopy ships with macOS)
  2. Ensure DISPLAY or WAYLAND_DISPLAY is set so clipboard backends can connect
  3. Run in a graphical session instead of a headless/containerized environment, or mock/skip clipboard use there
  4. Check that GROK_CLIPBOARD_NO_DATA_CONTROL or similar bypass env vars are not disabling the arboard leg

Example fix

// before
clipboard::set_text(&text)?;

// after
if let Err(e) = clipboard::set_text(&text) {
    eprintln!("clipboard unavailable: {e}; printing to stdout instead");
    println!("{text}");
}
Defensive patterns

Strategy: fallback

Validate before calling

// Pre-flight: check a clipboard write path exists before relying on it
fn clipboard_available() -> bool {
    #[cfg(target_os = "macos")]
    { std::process::Command::new("pbcopy").arg("-h").output().is_ok() }
    #[cfg(target_os = "linux")]
    { std::env::var_os("WAYLAND_DISPLAY").is_some() || std::env::var_os("DISPLAY").is_some() }
}

Try / catch

match clipboard::set_text(&text) {
    Ok(()) => {},
    Err(e) if e.to_string() == "no clipboard backend available" => {
        eprintln!("clipboard unavailable, printing instead");
        println!("{text}");
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling clipboard::set_text on a headless server (no X11/Wayland display), inside a container/sandbox without clipboard access, over SSH without DISPLAY/WAYLAND_DISPLAY set, or on macOS when both arboard and the pbcopy/osascript legs fail.

Common situations: CI runners, Docker containers, remote shells, WSL misconfiguration, or Linux sessions where no clipboard utility (xclip/xsel/wl-copy) is installed.

Related errors


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