gitui-org/gitui · error · anyhow::Error

`{command:?}`: {e:?}

Error message

`{command:?}`: {e:?}

What it means

gitui has no built-in clipboard: copy operations shell out to an external provider (wl-copy/wl-paste on Wayland, xclip, xsel, pbcopy, clip.exe, win32yank, or termux-clipboard-set depending on platform/session). exec_copy_with_args() resolves the binary with the which crate and spawns it; this error is that spawn failing at the OS level - overwhelmingly ErrorKind::NotFound (provider not installed or not on PATH) or PermissionDenied. The message embeds the full command line and the debug form of the io::Error.

Source

Thrown at src/clipboard.rs:27

	args: &[&str],
	text: &str,
	pipe_stderr: bool,
) -> Result<()> {
	let binary = which(command)
		.ok()
		.unwrap_or_else(|| PathBuf::from(command));

	let mut process = Command::new(binary)
		.args(args)
		.stdin(Stdio::piped())
		.stdout(Stdio::null())
		.stderr(if pipe_stderr {
			Stdio::piped()
		} else {
			Stdio::null()
		})
		.spawn()
		.map_err(|e| anyhow!("`{command:?}`: {e:?}"))?;

	process
		.stdin
		.as_mut()
		.ok_or_else(|| anyhow!("`{command:?}`"))?
		.write_all(text.as_bytes())
		.map_err(|e| anyhow!("`{command:?}`: {e:?}"))?;

	let out = process
		.wait_with_output()
		.map_err(|e| anyhow!("`{command:?}`: {e:?}"))?;

	if out.status.success() {
		Ok(())
	} else {
		let msg = if out.stderr.is_empty() {
			format!("{}", out.status).into()
		} else {

View on GitHub (pinned to 2fa693cb6e)

Solutions

  1. Install the provider matching your session: xclip or xsel (X11), wl-clipboard (Wayland), pbcopy (ships with macOS), win32yank or re-enabled interop for clip.exe (Windows/WSL), termux-api (Termux).
  2. Verify from the same shell/environment gitui runs in: echo test | xclip -selection clipboard (or | wl-copy) must succeed.
  3. Check the session variables are exported where gitui inherits them: echo $DISPLAY and echo $WAYLAND_DISPLAY.
  4. In ssh sessions, forward X (ssh -X) or run inside tmux with a terminal that supports OSC 52 clipboard escapes.

Example fix

# Debian/Ubuntu, X11
# before: gitui copy -> `"xclip -selection clipboard": Os { code: 2, kind: NotFound, ... }`
sudo apt install xclip
# after: copy works

# Arch + Wayland
sudo pacman -S wl-clipboard
Defensive patterns

Strategy: validation

Validate before calling

# shell: confirm a provider exists in the exact session gitui runs in
command -v xclip xsel wl-copy pbcopy clip.exe win32yank termux-clipboard-set 2>/dev/null

// Rust: cheap availability probe before spawning
use std::process::Command;
fn provider_available(cmd: &str) -> bool {
    let bin = cmd.split_whitespace().next().unwrap_or("");
    Command::new(bin).arg("--version")
        .stdout(std::process::Stdio::null())
        .stderr(std::process::Stdio::null())
        .status().is_ok()
}

Try / catch

match copy(text) {
    Err(e) if e.to_string().contains("NotFound") => { /* disable copy UI / inform user */ Ok(()) }
    other => other,
}

Prevention

When it happens

Trigger: Pressing the copy key (e.g. y on a commit or file) when no clipboard tool is installed; being on Wayland with only xclip installed or X11 with only wl-clipboard; running gitui over plain ssh where the remote lacks any provider; a PATH entry where the binary exists but is not executable.

Common situations: Minimal tiling-WM or server installs without xclip/wl-clipboard; ssh sessions into remote hosts; WSL with interop disabled so clip.exe is unreachable; NixOS/Arch systems where the clipboard package was never added.

Related errors


AI-assisted analysis of gitui-org/gitui@2fa693cb6e (2026-08-16). Data as JSON: /api/errors/30555aac2ae49dd9. Report an issue: GitHub.