gitbutlerapp/gitbutler · error · anyhow::Error

{terminal_name} exited with non-zero status: {status_code}

Error message

{terminal_name} exited with non-zero status: {status_code}

What it means

macOS branch of open_in_terminal: run_terminal_command (crates/but-api/src/open/mod.rs:391-414) executes the terminal launch command (usually `open -a <App> <path>`, or `wezterm start --cwd`) and waits for it. A non-zero exit with empty stderr produces this generic status message including the exit code.

Source

Thrown at crates/but-api/src/open/mod.rs:410

            use bstr::ByteSlice;

            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."
                )

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Run the same launch manually in Terminal (e.g. `open -a Ghostty /path/to/repo`) to surface the real failure
  2. Reinstall the terminal app or clear quarantine: xattr -dr com.apple.quarantine /Applications/<App>.app
  3. Confirm the passed path exists and is a directory, then try another terminal selected in Settings
  4. For wezterm, run `wezterm start --cwd /path` by hand to check its config
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await client.openInTerminal(terminalId, repoPath);
} catch (e) {
  const msg = String(e);
  if (msg.includes('exited with non-zero status')) {
    // show 'terminal failed to launch, pick another in Settings' + suggest
    // running `open -a <App> <path>` manually to see the cause
  } else throw e;
}

Prevention

When it happens

Trigger: `open -a` fails even though the earlier `open -Ra` availability probe succeeded: corrupted or quarantined app bundle, macOS refusing the launch, or a path argument the app rejects. Also the wezterm CLI exiting non-zero without writing to stderr.

Common situations: Terminal app updated/moved while GitButler runs; app translocation/quarantine after download; Gatekeeper prompt dismissed; path containing characters the app mishandles.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/8a40cbaaa2438107. Report an issue: GitHub.