{"record":{"id":"0fbc0da3595f483b","repo":"xai-org/grok-build","slug":"no-cli-tool-supports-image-clipboard-writes","errorCode":null,"errorMessage":"no CLI tool supports image clipboard writes","messagePattern":"no CLI tool supports image clipboard writes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":2176,"sourceCode":"                };\n                match run_pipe_in(argv, &data) {\n                    Ok(()) => any_ok = true,\n                    Err(e) => {\n                        tracing::debug!(\n                            \"CLI image clipboard write failed ({spec_name}): {e}\",\n                            spec_name = spec.name\n                        );\n                        last_err = Some(e);\n                    }\n                }\n            }\n            if any_ok {\n                return Ok(());\n            }\n            if let Some(e) = last_err {\n                return Err(e);\n            }\n            anyhow::bail!(\"no CLI tool supports image clipboard writes\");\n        }\n        #[cfg(not(target_os = \"linux\"))]\n        {\n            let _ = path;\n            anyhow::bail!(\"image clipboard not supported on this platform\")\n        }\n    }\n\n    /// Encode raw RGBA pixels into PNG bytes.\n    pub(super) fn encode_rgba_to_png(\n        rgba: &[u8],\n        width: u32,\n        height: u32,\n    ) -> anyhow::Result<Vec<u8>> {\n        use image::codecs::png::PngEncoder;\n        use image::{ColorType, ImageEncoder};\n\n        let expected_len = (width as usize) * (height as usize) * 4;","sourceCodeStart":2158,"sourceCodeEnd":2194,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L2158-L2194","documentation":"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.","triggerScenarios":"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.","commonSituations":"Minimal Linux installs lacking xclip/wl-clipboard image support; headless servers; distros shipping only xsel, which cannot write images.","solutions":["Install xclip (X11) or wl-clipboard's wl-copy (Wayland), which support image MIME targets","Verify image support by manually running `xclip -selection clipboard -t image/png -i file.png`","Fall back to copying the file path or text representation instead of image bytes"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"fn image_write_supported() -> bool {\n    which::which(\"xclip\").is_ok() || which::which(\"wl-copy\").is_ok()\n}","typeGuard":null,"tryCatchPattern":"match clipboard::set_image_file(&path) {\n    Err(e) if e.to_string().contains(\"no CLI tool supports image clipboard writes\") => {\n        eprintln!(\"image clipboard unsupported; copying file path instead\");\n        clipboard::set_text(&path.to_string_lossy())\n    }\n    other => other,\n}","preventionTips":["Install xclip (X11) or wl-clipboard (Wayland) with image MIME support in target images","Verify image support manually: `xclip -selection clipboard -t image/png -i f.png`","Ship a fallback (copy path/text) for platforms without image clipboard support","Detect support at startup rather than failing at first image copy"],"tags":["clipboard","image","linux"],"backgroundTag":"no-clipboard-backend","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}