Hmbown/CodeWhale · error
Failed to run
Error message
Failed to run {program}: {e} What it means
read_text_with_wlpaste_using_argv throws this when it fails to spawn the wl-paste process via Command::output(). The message wraps the raw spawn error (typically NotFound, PermissionDenied). It means the Wayland clipboard read could not even start the helper program, not that the paste failed afterwards.
Solutions
- Install the wl-clipboard package (wl-paste/wl-copy): e.g. apt install wl-clipboard / pacman -S wl-clipboard.
- Verify wl-paste resolves on PATH: which wl-paste (fix PATH in the service environment if missing).
- Confirm the session is Wayland (echo $WAYLAND_DISPLAY); on X11 use xclip/xsel instead.
- Check execute permission on the wl-paste binary.
- Handle the error by falling back to the library's other clipboard read backends.
Example fix
// before
let text = read_text_with_wlpaste()?;
// after
let text = read_text_with_wlpaste().or_else(|e| {
eprintln!("wl-paste unavailable ({e:#}); falling back");
read_text_with_osc52()
})?; Defensive patterns
Strategy: fallback
Validate before calling
use std::process::Command;
fn wl_paste_available() -> bool {
Command::new("wl-paste").arg("--no-newline")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status().map(|s| s.success()).unwrap_or(false)
}
if !wl_paste_available() { /* use another read backend */ } Try / catch
match read_text_with_wlpaste() {
Ok(t) => t,
Err(e) if e.to_string().contains("Failed to run") => {
eprintln!("wl-paste not runnable ({e:#}); falling back");
read_text_with_osc52().unwrap_or_default()
}
Err(e) => { eprintln!("clipboard read failed: {e:#}"); String::new() }
} Prevention
- Install the wl-clipboard package on all Wayland deployment targets.
- Smoke-test `which wl-paste` in CI/container images before shipping.
- Fix PATH for services/IDE-launched processes so the helper resolves.
- Fall back to X11 (xclip/xsel) or OSC52 backends when wl-paste is absent.
When it happens
Trigger: Calling read_text_with_wlpaste (or the test wl_paste_helper_reads_text_from_stdout) when the wl-paste binary does not exist on PATH, lacks execute permission, or the OS refuses the exec/fork (e.g. EAGAIN under heavy process limits).
Common situations: Running the TUI on X11 or macOS where wl-paste is not installed; a Wayland session without xdg-desktop-portal/wl-clipboard package; PATH stripped in a systemd service or cron context; wl-clipboard removed after a distro upgrade.
Related errors
- Failed to run tmux load-buffer -w
- clipboard read failed
- Failed to run
- Failed to wait on
- Failed to write to
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/ebc3e1b93bf2cdf6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/clipboard.rs:725
fn write_text_with_wlcopy(text: &str) -> Result<()> {
write_text_with_wlcopy_using_argv("wl-copy", text)
}
#[cfg(all(target_os = "linux", not(target_env = "ohos"), not(test)))]
fn read_text_with_wlpaste() -> Result<String> {
read_text_with_wlpaste_using_argv("wl-paste")
}
#[cfg(any(all(test, unix), all(target_os = "linux", not(target_env = "ohos"))))]
fn read_text_with_wlpaste_using_argv(program: &str) -> Result<String> {
let output = Command::new(program)
.arg("--no-newline")
.arg("--type")
.arg("text/plain")
.stdout(Stdio::piped())
.stderr(Stdio::null())
.output()
.map_err(|e| anyhow::anyhow!("Failed to run {program}: {e}"))?;
if !output.status.success() {
bail!("{program} exited with {}", output.status);
}
String::from_utf8(output.stdout).context("wl-paste returned non-UTF-8 text")
}
#[cfg(all(target_os = "linux", not(target_env = "ohos"), not(test)))]
fn write_text_with_wlcopy_using_argv(program: &str, text: &str) -> Result<()> {
let mut child = Command::new(program)
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.map_err(|e| anyhow::anyhow!("Failed to run {program}: {e}"))?;
if let Some(mut stdin) = child.stdin.take() {
stdin
.write_all(text.as_bytes())
.map_err(|e| anyhow::anyhow!("Failed to write to {program}: {e}"))?;View on GitHub (pinned to 433685b202)