{"record":{"id":"138f74709a69be02","repo":"nikivdev/code","slug":"clipboard-not-supported-on-this-platform","errorCode":null,"errorMessage":"clipboard not supported on this platform","messagePattern":"clipboard not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":14202,"sourceCode":"                .arg(\"--input\")\n                .stdin(Stdio::piped())\n                .spawn()\n                .context(\"failed to spawn xclip or xsel\")?,\n        };\n\n        if let Some(stdin) = child.stdin.as_mut() {\n            stdin.write_all(text.as_bytes())?;\n        }\n\n        let status = child.wait()?;\n        if !status.success() {\n            bail!(\"clipboard command exited with status {}\", status);\n        }\n    }\n\n    #[cfg(not(any(target_os = \"macos\", target_os = \"linux\")))]\n    {\n        bail!(\"clipboard not supported on this platform\");\n    }\n\n    Ok(())\n}\n\n/// Strip <thinking> blocks from content (internal Claude processing).\nfn strip_thinking_blocks(s: &str) -> String {\n    let mut remaining = s;\n    let mut out = String::new();\n\n    loop {\n        let Some(start) = remaining.find(\"<thinking>\") else {\n            out.push_str(remaining);\n            break;\n        };\n\n        out.push_str(&remaining[..start]);\n        let after_start = &remaining[start + \"<thinking>\".len()..];","sourceCodeStart":14184,"sourceCodeEnd":14220,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L14184-L14220","documentation":"The clipboard helper is explicitly platform-gated: macOS uses pbcopy, Linux uses xclip/xsel, and any other target (Windows, BSDs, etc.) hits a `#[cfg(not(any(target_os = \"macos\", target_os = \"linux\")))]` block that unconditionally bails with this message. The feature simply has no implementation for that platform.","triggerScenarios":"Calling any clipboard-copy command on a non-macOS/non-Linux target — e.g. building/running on Windows natively; cross-compiling and running the binary on an unsupported OS.","commonSituations":"Windows users running the tool natively (works fine under WSL, which reports Linux); CI runners on Windows; contributors testing the clipboard path on an unusual platform.","solutions":["Run the tool under WSL on Windows, where target_os is linux and the xclip/xsel path applies","Add support: install a clipboard helper and patch the helper to shell out to `clip.exe` (Windows) or use the `arboard`/`cli-clipboard` crate for portable clipboard access","Avoid the copy command on unsupported platforms and redirect output to a file/stdout instead"],"exampleFix":"// before (src/ai.rs)\n#[cfg(not(any(target_os = \"macos\", target_os = \"linux\")))]\n{\n    bail!(\"clipboard not supported on this platform\");\n}\n// after\n#[cfg(target_os = \"windows\")]\n{\n    let mut child = Command::new(\"clip\")\n        .stdin(Stdio::piped())\n        .spawn()?;\n    child.stdin.as_mut().unwrap().write_all(text.as_bytes())?;\n    child.wait()?;\n}\n#[cfg(not(any(target_os = \"macos\", target_os = \"linux\", target_os = \"windows\")))]\n{\n    bail!(\"clipboard not supported on this platform\");\n}","handlingStrategy":"fallback","validationCode":"#[cfg(target_os = \"unknown-platform\")]\ncompile_error!(\"clipboard unsupported; build on macOS/Linux or use WSL on Windows\");\n\n// runtime guard\nfn clipboard_supported() -> bool {\n    cfg!(any(target_os = \"macos\", target_os = \"linux\"))\n}\nif !clipboard_supported() {\n    eprintln!(\"no clipboard support; writing to file instead\");\n    std::fs::write(\"out.txt\", text).unwrap();\n    return;\n}","typeGuard":null,"tryCatchPattern":"match copy_to_clipboard(text) {\n    Err(e) if e.to_string() == \"clipboard not supported on this platform\" => {\n        eprintln!(\"platform unsupported; saved output to file instead\");\n        std::fs::write(\"clipboard-fallback.txt\", text)?;\n    }\n    other => other?,\n}","preventionTips":["On Windows, run the tool under WSL so the Linux clipboard path applies","Check the platform gate before building clipboard-dependent automation for non-macOS/Linux targets","Contribute or wire in a portable clipboard crate (e.g. arboard) if you need native Windows support","Keep a file/stdout fallback in scripts so unsupported platforms degrade gracefully"],"tags":["clipboard","platform-support","unsupported-platform","windows"],"backgroundTag":"unsupported-platform","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}