gitbutlerapp/gitbutler · error
Failed to open ( )
Error message
Failed to open {terminal_name} ({status_code}): {stderr} What it means
The stderr-present sibling of error 142: the terminal emulator's launch command exited non-zero and printed a diagnostic to stderr, so run_terminal_command() includes the terminal name, status code, and stderr text in the error. This is the more informative variant and usually pinpoints the actual launch problem.
Solutions
- Read the stderr in the message and fix the reported terminal problem
- Correct the terminal's configuration file referenced in stderr
- Check the flags open_in_terminal passes for your terminal version and adjust/upgrade the terminal
- Ensure the terminal has access to the target directory (sandbox/permission issues)
Example fix
// before (broken alacritty config)
// bail!("Failed to open Alacritty (1): error parsing alacritty.yml")
// after: fix alacritty.yml, then
open_in_terminal("alacritty", path) Defensive patterns
Strategy: try-catch
Try / catch
match open_in_terminal(terminal_id, &path) {
Err(e) if e.to_string().starts_with("Failed to open ") => {
// surface stderr from the message to the user; offer another terminal
eprintln!("Terminal launch failed: {e}");
open_in_terminal("fallback-terminal", &path)?;
}
r => r?,
} Prevention
- Read the stderr in the message — it names the actual terminal problem
- Keep terminal config files (alacritty.yml, wezterm.lua) syntactically valid
- Match CLI flags to the installed terminal version
When it happens
Trigger: open_in_terminal launches a terminal whose process exits non-zero and writes an error message to stderr (bad flag, missing profile, config parse error, etc.).
Common situations: Passing unsupported CLI flags to the terminal, a broken terminal config (e.g. invalid wezterm.lua or alacritty.yml), terminal not liking the --working-directory value, or a snap/flatpak-confined terminal refusing access.
Related errors
- exited with non-zero status
- DefaultTerminalNotFound
- Editor exited with non-zero status
- EditorExitedWithNonZeroStatus
- Errors occurred
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/2be9713ffe8950da.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/open/mod.rs:412
tracing::info!(?cmd, "terminal command");
let output = cmd
.output()
.with_context(|| format!("Failed to launch {terminal_name} at '{path}'"))?;
if output.status.success() {
return Ok(());
}
let stderr = output.stderr.to_str_lossy();
let stderr = stderr.trim();
let status_code = output
.status
.code()
.map_or("unknown".to_string(), |c| c.to_string());
if stderr.is_empty() {
bail!("{terminal_name} exited with non-zero status: {status_code}",);
} else {
bail!("Failed to open {terminal_name} ({status_code}): {stderr}");
}
}
/// Check if a macOS application is installed using `open -Ra`.
fn ensure_app_installed(app_name: &str) -> Result<()> {
let status = Command::new("open")
.arg("-Ra")
.arg(app_name)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.context("Failed to run 'open -Ra' to check application availability")?;
if !status.success() {
return Err(anyhow::anyhow!(
"'{app_name}' was not found - `open -Ra {app_name}` failed."
)
.context(but_error::Code::DefaultTerminalNotFound));
}View on GitHub (pinned to 58e5313667)