xai-org/grok-build · error

no CLI tool supports image clipboard writes

Error message

no CLI tool supports image clipboard writes

What it means

On Linux, image clipboard writes are attempted through a set of CLI tools; if none of them succeeded and no last_err was recorded (i.e. no candidate tool was even applicable), the library bails with this sentinel message. It means the current platform/toolset has no supported path for writing images to the clipboard.

Source

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

                };
                match run_pipe_in(argv, &data) {
                    Ok(()) => any_ok = true,
                    Err(e) => {
                        tracing::debug!(
                            "CLI image clipboard write failed ({spec_name}): {e}",
                            spec_name = spec.name
                        );
                        last_err = Some(e);
                    }
                }
            }
            if any_ok {
                return Ok(());
            }
            if let Some(e) = last_err {
                return Err(e);
            }
            anyhow::bail!("no CLI tool supports image clipboard writes");
        }
        #[cfg(not(target_os = "linux"))]
        {
            let _ = path;
            anyhow::bail!("image clipboard not supported on this platform")
        }
    }

    /// Encode raw RGBA pixels into PNG bytes.
    pub(super) fn encode_rgba_to_png(
        rgba: &[u8],
        width: u32,
        height: u32,
    ) -> anyhow::Result<Vec<u8>> {
        use image::codecs::png::PngEncoder;
        use image::{ColorType, ImageEncoder};

        let expected_len = (width as usize) * (height as usize) * 4;

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Install xclip (X11) or wl-clipboard's wl-copy (Wayland), which support image MIME targets
  2. Verify image support by manually running `xclip -selection clipboard -t image/png -i file.png`
  3. Fall back to copying the file path or text representation instead of image bytes
Defensive patterns

Strategy: fallback

Validate before calling

fn image_write_supported() -> bool {
    which::which("xclip").is_ok() || which::which("wl-copy").is_ok()
}

Try / catch

match clipboard::set_image_file(&path) {
    Err(e) if e.to_string().contains("no CLI tool supports image clipboard writes") => {
        eprintln!("image clipboard unsupported; copying file path instead");
        clipboard::set_text(&path.to_string_lossy())
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling set_image_file on Linux when no supported image-capable CLI tool is available or no attempt produced a last error — e.g. neither xclip (with image targets) nor wl-copy image support is installed.

Common situations: Minimal Linux installs lacking xclip/wl-clipboard image support; headless servers; distros shipping only xsel, which cannot write images.

Related errors


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