Hmbown/CodeWhale · error
exited with
Error message
{program} exited with {} What it means
`read_text_with_wlpaste_using_argv` runs an external Wayland clipboard reader (`wl-paste` or a configured helper) and requires it to exit successfully. When the program exits with a nonzero status, the function bails with this message instead of returning whatever partial stdout the program produced. It indicates the external clipboard helper itself failed, e.g. no Wayland clipboard manager is running.
Solutions
- Verify a Wayland session and clipboard manager are running (e.g. `wl-paste -n text/plain` manually returns data)
- Check that the configured helper program exists and works; fall back to the default `wl-paste`
- Ensure `WAYLAND_DISPLAY`/`XDG_RUNTIME_DIR` are set for the process environment
- Handle the error and fall back to another clipboard backend (X11, OSC 52 read, internal buffer)
Example fix
// before
let text = clipboard.read_text_with_wlpaste()?;
// after
let text = match clipboard.read_text_with_wlpaste() {
Ok(t) => t,
Err(e) => { eprintln!("clipboard read failed: {e}"); String::new() }
}; Defensive patterns
Strategy: try-catch
Validate before calling
let probe = Command::new("wl-paste").arg("--no-newline").arg("text/plain").status();
if !probe.map(|s| s.success()).unwrap_or(false) {
// wl-paste unusable; choose another backend before calling read_text_with_wlpaste
} Try / catch
let text = clipboard.read_text_with_wlpaste().unwrap_or_else(|e| {
log::warn!("wl-paste failed: {e}");
String::new()
}); Prevention
- Verify a Wayland clipboard source exists before relying on wl-paste
- Keep WAYLAND_DISPLAY/XDG_RUNTIME_DIR set in the process environment
- Probe the helper once at startup and cache which backend works
- Configure a known-good helper path rather than relying on defaults on headless boxes
When it happens
Trigger: Calling `read_text_with_wlpaste` when the wl-paste helper binary exits nonzero — typically when no Wayland compositor/clipboard source is available, the Wayland display is unreachable, or the helper is misconfigured to a nonexistent wrapper script.
Common situations: Reading the clipboard over SSH into a machine without a Wayland session; running in a window manager with no clipboard daemon; `wl-paste` not installed for the current compositor; a custom helper program that returns an error status.
Related errors
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/1f67294e320713e6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/clipboard.rs:727
}
#[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}"))?;
}
// stdin is dropped here, closing the pipe so wl-copy flushes.View on GitHub (pinned to 73e0f67d83)