xai-org/grok-build · error
image clipboard not supported on this platform
Error message
image clipboard not supported on this platform
What it means
The clipboard image-write helper only implements Linux (via CLI tools like xclip/wl-copy); on every other target OS it unconditionally fails with this bail. The library intentionally refuses to guess platform-specific clipboard APIs, so image clipboard writes are Linux-only by design.
Source
Thrown at crates/codegen/xai-grok-shared/src/clipboard.rs:2181
"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;
if rgba.len() < expected_len {
anyhow::bail!(
"RGBA buffer too short: expected at least {} bytes for {}x{}, got {}",
expected_len,
width,View on GitHub (pinned to bc7f02eddd)
Solutions
- Guard the call with #[cfg(target_os = "linux")] or a runtime OS check and skip/degrade gracefully on other platforms.
- Implement a platform backend (macOS: osascript/NSPasteboard, Windows: clipboard-win) and replace the cfg(not(...)) bail branch.
- Fall back to writing the PNG to a temp file and informing the user instead of copying to the clipboard.
Example fix
// before
clipboard::copy_image(&png_bytes)?;
// after
#[cfg(target_os = "linux")]
clipboard::copy_image(&png_bytes)?;
#[cfg(not(target_os = "linux"))]
eprintln!("image clipboard unsupported on this platform; saved to file instead"); Defensive patterns
Strategy: fallback
Validate before calling
// compile-time gate
#[cfg(target_os = "linux")]
fn clipboard_image_supported() -> bool { true }
#[cfg(not(target_os = "linux"))]
fn clipboard_image_supported() -> bool { false } Try / catch
match clipboard::copy_image(&png) {
Ok(()) => {},
Err(e) if e.to_string().contains("not supported on this platform") => {
// fallback: write to temp file
std::fs::write("/tmp/image.png", &png)?;
eprintln!("clipboard unavailable; image saved to /tmp/image.png");
}
Err(e) => return Err(e),
} Prevention
- Gate all clipboard image code behind #[cfg(target_os = "linux")] or a runtime feature check
- Document platform support in the API so callers can branch before calling
- Always provide a file-based fallback path for image export
When it happens
Trigger: Calling the image clipboard write function (which encode_rgba_to_png feeds) compiled for any target_os other than linux, e.g. macOS or Windows builds; the cfg(not(target_os = "linux")) branch always bails with this message.
Common situations: Running a screenshot/copy-image feature on macOS or Windows builds; cross-platform code that assumes clipboard image support exists everywhere; CI on non-Linux runners exercising the clipboard path.
Related errors
- no clipboard backend available
- {label} exited with {}: {}
- pbcopy exited with status {status}
- osascript failed: {stderr}
- arboard leg disabled (GROK_CLIPBOARD_NO_DATA_CONTROL)
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/b49b2518948eaef9.
Report an issue: GitHub.