gitbutlerapp/gitbutler · warning
command exited with status
Error message
command exited with status {} What it means
After a TUI command-mode command finishes, the exit status is inspected. On non-zero exit the code surfaces `command exited with status {status}` as a transient error, so the user sees the child failed while the TUI itself stays alive (successful runs instead trigger a workspace reload).
Solutions
- read the command's stdout/stderr output (shown during the run) to find the underlying failure
- fix the underlying command failure (build errors, hook rejections, missing auth) and re-run
- run the command in a separate terminal if it needs interactive stdin the TUI cannot supply
Example fix
// before > but push # rejected by pre-push hook // after # fix hook failure in a terminal, then in TUI: > but push
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check command success expectations
if !Command::new("sh").arg("-c").arg(&format!("{cmd} --help")).status().map(|s| s.success()).unwrap_or(false) { eprintln!("{cmd} may fail; run it in a terminal first"); } Try / catch
match run_tui_command(cmd) {
Err(e) if e.to_string().starts_with("command exited with status") => {
eprintln!("Fix the underlying failure shown in the command output, then re-run.");
}
other => other?,
} Prevention
- test commands in a regular terminal before running them in the TUI
- avoid commands requiring interactive stdin inside the TUI
- ensure credentials/auth are set up for push/pull commands
When it happens
Trigger: Running any shell command in the TUI command mode whose process terminates with a non-zero status: failing builds/tests, `git` operations rejected by hooks, commands killed by signals, or scripts with `exit 1`.
Common situations: Running `npm test` with failing tests, `git push` rejected by a remote hook, `make` compilation errors, or commands that need credentials/stdin the suspended TUI cannot provide.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- Editor cancelled
- File suffix ' ' is not allowed. Must be one of
- No diffs to show.
- Aborting due to empty branch name
- Aborting due to empty
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/ce577c449ac6ec76.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/status/tui/app/command_mode.rs:242
return Ok(());
} else {
return Err(err).context("failed to start command");
}
}
};
let status = child.wait()?;
if !IN_TEST {
out.prompt_single_line("\npress enter to continue...")?;
}
if status.success() {
messages.extend([
Message::EnterNormalModeAfterConfirmingOperation,
Message::Reload(None, ReloadCause::Mutation),
]);
} else {
self.push_transient_error(anyhow!(
"command exited with status {}",
format_exit_status(status)
));
}
drop(_suspend_guard);
Ok(())
}
}
/// Formats an exit status for human-readable error messages.
fn format_exit_status(status: std::process::ExitStatus) -> String {
if let Some(code) = status.code() {
code.to_string()
} else {
status.to_string()
}View on GitHub (pinned to 58e5313667)