Hmbown/CodeWhale · error · anyhow::Error
Failed to run {label}: {e}
Error message
Failed to run {label}: {e} What it means
write_text_with_stdin_command (used for macOS pbcopy and Windows `powershell.exe -NoProfile -Command Set-Clipboard -Value $input`) could not spawn the helper process. The OS error names the cause: typically NotFound (binary not on the TUI process's PATH), PermissionDenied, or a fork/exec resource limit. Inside the fallback chain, this error is swallowed unless every later transport also fails.
Source
Thrown at crates/tui/src/tui/clipboard.rs:537
text,
"Set-Clipboard",
)
}
#[cfg(all(any(target_os = "macos", target_os = "windows"), not(test)))]
fn write_text_with_stdin_command(
program: &str,
args: &[&str],
text: &str,
label: &str,
) -> Result<()> {
let mut child = Command::new(program)
.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.map_err(|e| anyhow::anyhow!("Failed to run {label}: {e}"))?;
if let Some(mut stdin) = child.stdin.take() {
stdin
.write_all(text.as_bytes())
.map_err(|e| anyhow::anyhow!("Failed to write to {label}: {e}"))?;
}
let _ = std::thread::Builder::new()
.name("clipboard-wait".to_string())
.spawn(move || {
let _ = child.wait();
});
Ok(())
}
#[cfg(all(target_os = "linux", not(target_env = "ohos"), not(test)))]
fn write_text_with_wlcopy(text: &str) -> Result<()> {
write_text_with_wlcopy_using_argv("wl-copy", text)
}
View on GitHub (pinned to 0c42157ee5)
Solutions
- Run `which pbcopy` (macOS) or `where powershell.exe` (Windows) in the exact environment the TUI launches from
- Fix the launch environment so PATH includes /usr/bin:/bin (macOS) or the WindowsPowerShell System32 dir
- Repair the install: pbcopy ships with macOS, so a missing binary signals a broken system
- Rely on the terminal-client fallback instead: use an OSC 52-capable terminal or tmux
Example fix
# before: wrapper strips PATH PATH=/custom/bin codewhale tui # -> Failed to run pbcopy: No such file or directory (os error 2) # after PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH codewhale tui
Defensive patterns
Strategy: validation
Validate before calling
// Rust - preflight helper availability before relying on it
fn helper_available(program: &str) -> bool {
std::process::Command::new(program)
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.is_ok()
} Try / catch
if !helper_available("pbcopy") { use_osc52_fallback(); } else { /* proceed */ } Prevention
- Launch the TUI with an inherited, standard PATH (no stripped wrapper environments)
- Smoke-test platform helpers after system upgrades
- Treat helper spawn failure as 'fall through to next transport', never as fatal
When it happens
Trigger: Command::new(program).spawn() returns Err for pbcopy/powershell.exe: the binary is absent from PATH in the TUI's environment, not executable, blocked by a macOS sandbox policy, or the process limit is exhausted.
Common situations: PATH stripped by launcher/service/wrapper scripts; hardened macOS sandboxing; PowerShell relocated or not on PATH on Windows; containers with minimal images.
Related errors
- Failed to run tmux load-buffer -w: {e}
- config lock path {} contains invalid Unicode and cannot be c
- Failed to write to {label}: {e}
- Failed to run {program}: {e}
- NotFound
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/f650869028337db0.
Report an issue: GitHub.