tonhowtf/omniget · error

No clipboard tool found (tried xclip, xsel, wl-copy)

Error message

No clipboard tool found (tried xclip, xsel, wl-copy)

What it means

copy_file_linux tries three clipboard tools in order: xclip, xsel, and wl-copy. If all three are missing, fail to spawn, or report failure, it returns this terminal error. It means the machine has no supported clipboard utility available for the file-copy operation.

Solutions

  1. Install a clipboard tool: `sudo apt install xclip` (X11) or `sudo apt install wl-clipboard` (Wayland).
  2. Ensure DISPLAY (X11) or WAYLAND_DISPLAY (Wayland) environment variables are set and a clipboard daemon is running.
  3. On headless systems, avoid the file-to-clipboard feature entirely or use an alternative transfer mechanism.
  4. Check each tool manually (xclip -selection clipboard, xsel, wl-copy) to see which one fails and why.

Example fix

// before
Err(anyhow::anyhow!("No clipboard tool found (tried xclip, xsel, wl-copy)"))

// after
// Precondition check by the caller before invoking clipboard copy
if std::process::Command::new("which").arg("xclip").output().map(|o| !o.status.success()).unwrap_or(true)
    && env::var("DISPLAY").is_err() && env::var("WAYLAND_DISPLAY").is_err() {
    eprintln!("Clipboard unavailable: install xclip or wl-clipboard and set DISPLAY/WAYLAND_DISPLAY");
}
Defensive patterns

Strategy: validation

Validate before calling

fn clipboard_tool_available() -> Option<&'static str> {
    for tool in ["xclip", "xsel", "wl-copy"] {
        if std::process::Command::new("which").arg(tool).output()
            .map(|o| o.status.success()).unwrap_or(false) {
            return Some(tool);
        }
    }
    None
}

Try / catch

match clipboard_tool_available() {
    None => {
        eprintln!("No clipboard tool available; install xclip or wl-clipboard");
        // skip clipboard feature gracefully
    }
    Some(_) => copy_file_to_clipboard(path).await?,
}

Prevention

When it happens

Trigger: copy_file_to_clipboard called on Linux where xclip, xsel, and wl-copy are either not installed, not on PATH, or all exit non-zero / fail to accept the file URI.

Common situations: Headless servers/containers with no X11 or Wayland clipboard; minimal Docker images; SSH sessions without a display (no DISPLAY/WAYLAND_DISPLAY env vars); broken desktop environments.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/0866ca2d8d3255f0. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/clipboard.rs:147

            use std::io::Write;
            let _ = stdin.write_all(uri_clone.as_bytes());
        }
        let output = child.wait_with_output()?;
        if output.status.success() {
            Ok(true)
        } else {
            Ok(false)
        }
    })
    .await
    .map_err(|e| anyhow::anyhow!("{}", e))?;

    if let Ok(true) = wl_result {
        tracing::info!("[clipboard] copied file to clipboard (wl-copy): {}", path);
        return Ok(());
    }

    Err(anyhow::anyhow!(
        "No clipboard tool found (tried xclip, xsel, wl-copy)"
    ))
}

#[cfg(target_os = "windows")]
async fn copy_file_windows(path: &str) -> anyhow::Result<()> {
    let ps_script = format!("Set-Clipboard -LiteralPath '{}'", path.replace('\'', "''"));

    let output = tokio::task::spawn_blocking(move || {
        crate::core::process::std_command("powershell")
            .args(["-NoProfile", "-NonInteractive", "-Command", &ps_script])
            .output()
    })
    .await
    .map_err(|e| anyhow::anyhow!("spawn_blocking failed: {}", e))??;

    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr);

View on GitHub (pinned to 8600b91f42)