Hmbown/CodeWhale · error · anyhow::Error
Failed to run {program}: {e}
Error message
Failed to run {program}: {e} What it means
read_text_with_wlpaste_using_argv failed to spawn `wl-paste --no-newline --type text/plain`, the first paste attempt on Linux. The OS error is appended and almost always means the wl-clipboard package is missing or unreachable in PATH. ClipboardHandler::read swallows this and falls back to arboard, so it becomes user-visible only when every read path fails.
Source
Thrown at crates/tui/src/tui/clipboard.rs:570
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 0c42157ee5)
Solutions
- Install wl-clipboard: `apt install wl-clipboard` / `dnf install wl-clipboard` / `pacman -S wl-clipboard`
- Verify `wl-paste --no-newline --type text/plain` succeeds in the same shell the TUI launches from
- Ensure PATH includes /usr/bin; restart the TUI after installing
Defensive patterns
Strategy: validation
Validate before calling
// Rust - check wl-paste presence before attempting a Wayland read
fn wlpaste_available() -> bool {
which::which("wl-paste").is_ok()
&& std::env::var_os("WAYLAND_DISPLAY").is_some_and(|v| !v.is_empty())
} Try / catch
if wlpaste_available() { /* try wl-paste first */ } else { skip_to_arboard_fallback(); } Prevention
- Install wl-clipboard as part of the workstation setup on Wayland Linux
- Keep the TUI's PATH identical to the interactive shell
- Do not assume wl-paste exists on X11-only or headless systems
When it happens
Trigger: Command::new("wl-paste").output() returns Err: wl-clipboard not installed, PATH lacking the binary's directory, file present but not executable, or process/resource limits blocking spawn.
Common situations: Fresh distro without wl-clipboard; X11-only sessions; TUI launched from systemd/launcher with minimal PATH; container images.
Related errors
- Failed to write to {program}: {e}
- {program} exited with {}
- {program} exited with {status}
- Failed to run {label}: {e}
- Failed to wait on {program}: {e}
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/ebc3e1b93bf2cdf6.
Report an issue: GitHub.