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

`{command:?}`

Error message

`{command:?}`

What it means

After spawning the clipboard process with .stdin(Stdio::piped()), the code reaches for process.stdin. That Option can only be None if the child was spawned without piped stdin - an invariant violation between the spawn configuration shown and std's Child handle, not an environmental condition. With the given spawn options this branch is effectively unreachable; encountering it indicates a std-level inconsistency or a local modification that dropped the piped stdin.

Source

Thrown at src/clipboard.rs:32

		.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 {
			String::from_utf8_lossy(&out.stderr)
		};
		Err(anyhow!("`{command:?}`: {msg}"))
	}
}

View on GitHub (pinned to 2fa693cb6e)

Solutions

  1. If you modified the spawn options, keep .stdin(Stdio::piped()) and take the handle before calling wait_with_output().
  2. Upgrade gitui - the clipboard module was reworked in later releases with OSC 52 terminal-escape support.
  3. File an upstream issue with the panic location and trace if it reproduces on an unmodified current build.

Example fix

// before
let mut process = Command::new(binary).stdin(Stdio::piped()).spawn()?;
process.stdin.as_mut().ok_or_else(|| anyhow!("`{command:?}`"))?.write_all(text.as_bytes())?;
// after: take() once, drop to signal EOF
let mut stdin = process.stdin.take().ok_or_else(|| anyhow!("`{command:?}`"))?;
stdin.write_all(text.as_bytes())?;
drop(stdin); // close so providers like xclip see EOF and flush
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Effectively unreachable in shipped gitui builds; would require refactoring the spawn options away from Stdio::piped() while keeping this access, or a bug in std's Child construction.

Common situations: Only when hacking on gitui's clipboard module and changing the Stdio configuration; not observed in the field.

Related errors


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