nikivdev/code · error

clipboard not supported on this platform

Error message

clipboard not supported on this platform

What it means

The copy-to-clipboard helper supports macOS (pbcopy) and Linux (xclip/xsel). On any other target OS the compile-time cfg block has no implementation, so it unconditionally throws 'clipboard not supported on this platform'. It is a platform-support limitation, not a runtime misconfiguration.

Source

Thrown at src/commit.rs:7493

            Err(_) => Command::new("xsel")
                .arg("--clipboard")
                .arg("--input")
                .stdin(Stdio::piped())
                .spawn()
                .context("failed to spawn xclip or xsel")?,
        };

        if let Some(stdin) = child.stdin.as_mut() {
            stdin.write_all(text.as_bytes())?;
        }

        child.wait()?;
        return Ok(true);
    }

    #[cfg(not(any(target_os = "macos", target_os = "linux")))]
    {
        bail!("clipboard not supported on this platform");
    }
}

fn build_review_prompt_payload(
    repo_root: &Path,
    entry: &CommitQueueEntry,
    report_path: Option<&Path>,
) -> String {
    let (branch_other, total_other, current_branch) = queued_review_counts_excluding(
        repo_root,
        &entry.commit_sha,
    )
    .unwrap_or((0, 0, "unknown".to_string()));
    let mut out = String::new();
    out.push_str("here is commit i want you to address fully\n\n");
    out.push_str(&format!(
        "Repo: {}\nBranch: {}\nQueued commit: {}",
        repo_root.display(),

View on GitHub (pinned to a747e741ae)

Solutions

  1. Copy the text manually from the tool's printed output
  2. Run under WSL with clipboard bridging or an X server providing xclip/xsel
  3. Patch the helper to add support for your platform (e.g. `clip.exe` on Windows via /mnt/c/Windows/System32/clip.exe)
  4. File/await an upstream feature request for Windows clipboard support

Example fix

// before
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
{
    bail!("clipboard not supported on this platform");
}
// after
#[cfg(target_os = "windows")]
{
    let mut child = Command::new("C:\\Windows\\System32\\clip.exe")
        .stdin(Stdio::piped()).spawn()?;
    child.stdin.as_mut().unwrap().write_all(text.as_bytes())?;
    child.wait()?;
    return Ok(true);
}
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
{
    bail!("clipboard not supported on this platform");
}
Defensive patterns

Strategy: fallback

Validate before calling

#[cfg(any(target_os = "macos", target_os = "linux"))]
let clipboard_ok = true;
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
let clipboard_ok = false;
if !clipboard_ok { eprintln!("clipboard unavailable; printing text instead"); }

Type guard

fn clipboard_supported() -> bool {
    cfg!(any(target_os = "macos", target_os = "linux"))
}

Try / catch

match tool.copy_to_clipboard(text) {
    Err(e) if e.to_string().contains("clipboard not supported") => {
        println!("{}", text); // print instead of copying
    }
    other => other?,
}

Prevention

When it happens

Trigger: Invoking the clipboard-copy feature (e.g. copying a commit message/review link) on Windows, BSD, or any OS other than macOS or Linux.

Common situations: Running the tool on Windows (native or under some non-WSL environment), or cross-compiling/running in environments without a clipboard server (headless Linux without X11 also fails earlier at the xclip/xsel spawn step).

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/d1e3c9c25dbb4aef. Report an issue: GitHub.