{"record":{"id":"f6c4bee490cd9518","repo":"xai-org/grok-build","slug":"no-clipboard-backend-available","errorCode":null,"errorMessage":"no clipboard backend available","messagePattern":"no clipboard backend available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":287,"sourceCode":"    /// arboard write landed; a focus-free authoritative write additionally\n    /// requires `arboard_ok`. Always false on macOS/Windows/X11.\n    pub data_control: bool,\n    /// True when at least one leg succeeded.\n    pub any_ok: bool,\n}\n\n/// Write text and return per-leg outcomes for telemetry callers.\npub fn set_text_with_outcome(text: &str) -> NativeWriteOutcome {\n    platform::set_text_with_outcome(text)\n}\n\n/// Write text to the system clipboard.\npub fn set_text(text: &str) -> anyhow::Result<()> {\n    let outcome = platform::set_text_with_outcome(text);\n    if outcome.any_ok {\n        Ok(())\n    } else {\n        anyhow::bail!(\"no clipboard backend available\")\n    }\n}\n\n/// Copy an image file to the system clipboard.\n///\n/// On macOS, uses `osascript` to set the pasteboard from a file path.\n/// On Linux, uses `wl-copy` or `xclip` if available.\n/// On Windows, returns an error (not yet supported).\npub fn set_image_file(path: &std::path::Path) -> anyhow::Result<()> {\n    platform::set_image_file(path)\n}\n\n/// The clipboard tool used for native writes on the current platform.\n///\n/// Returns `\"pbcopy\"` on macOS, `\"arboard\"` on Windows, and the probed CLI\n/// tool name on Linux (or `\"arboard\"` if no CLI tool was found).\npub fn native_tool_name() -> &'static str {\n    #[cfg(target_os = \"macos\")]","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L269-L305","documentation":"`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.","triggerScenarios":"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.","commonSituations":"CI runners, Docker containers, remote shells, WSL misconfiguration, or Linux sessions where no clipboard utility (xclip/xsel/wl-copy) is installed.","solutions":["Install a clipboard CLI tool (xclip or xsel for X11, wl-clipboard for Wayland; pbcopy ships with macOS)","Ensure DISPLAY or WAYLAND_DISPLAY is set so clipboard backends can connect","Run in a graphical session instead of a headless/containerized environment, or mock/skip clipboard use there","Check that GROK_CLIPBOARD_NO_DATA_CONTROL or similar bypass env vars are not disabling the arboard leg"],"exampleFix":"// before\nclipboard::set_text(&text)?;\n\n// after\nif let Err(e) = clipboard::set_text(&text) {\n    eprintln!(\"clipboard unavailable: {e}; printing to stdout instead\");\n    println!(\"{text}\");\n}","handlingStrategy":"fallback","validationCode":"// Pre-flight: check a clipboard write path exists before relying on it\nfn clipboard_available() -> bool {\n    #[cfg(target_os = \"macos\")]\n    { std::process::Command::new(\"pbcopy\").arg(\"-h\").output().is_ok() }\n    #[cfg(target_os = \"linux\")]\n    { std::env::var_os(\"WAYLAND_DISPLAY\").is_some() || std::env::var_os(\"DISPLAY\").is_some() }\n}","typeGuard":null,"tryCatchPattern":"match clipboard::set_text(&text) {\n    Ok(()) => {},\n    Err(e) if e.to_string() == \"no clipboard backend available\" => {\n        eprintln!(\"clipboard unavailable, printing instead\");\n        println!(\"{text}\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Detect headless environments (no DISPLAY/WAYLAND_DISPLAY) early and skip clipboard features","Install xclip/xsel or wl-clipboard in Docker images and CI runners","Avoid unsetting/diabling backends via env vars like GROK_CLIPBOARD_NO_DATA_CONTROL unless needed","Provide a print-to-stdout or file fallback for clipboard writes"],"tags":["clipboard","environment","linux"],"backgroundTag":"no-clipboard-backend","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}