gitbutlerapp/gitbutler · error
Editor exited with non-zero status
Error message
Editor exited with non-zero status
What it means
`edit_commit_message` opens the user's configured editor to change a commit message; the underlying edit operation returned `but_error::Code::EditorExitedWithNonZeroStatus`, which is mapped to this message. It means the external editor process exited with failure, so no (valid) edited message was produced.
Solutions
- Check GIT_EDITOR/EDITOR is set to a working CLI editor (e.g. `export EDITOR=vim` or `code --wait` for VS Code)
- Run the editor manually on a scratch file to confirm it exits 0 on save
- Retry the reword, providing the new message directly if supported instead of the editor flow
- Inspect the editor's own stderr — the original error is preserved when it is not an EditorExitedWithNonZeroStatus code
Example fix
// before EDITOR="code" but reword <commit> # VS Code exits without --wait // after export EDITOR="code --wait" but reword <commit>
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the editor exits 0 on save echo test > /tmp/editcheck && "$EDITOR" /tmp/editcheck && rm /tmp/editcheck || echo 'Editor broken'
Try / catch
match but reword <commit>:
on failure matching 'Editor exited with non-zero status':
retry with EDITOR=vim (or pass message directly) and surface editor stderr Prevention
- Set EDITOR to a terminal editor or use --wait flags for GUI editors
- Test your editor setup once with `git commit` before using but reword
- Avoid killing the editor process; cancel cleanly instead
When it happens
Trigger: Calling `but reword` (run/execute → edit_commit_message) when the configured editor (GIT_EDITOR, EDITOR, or default) terminates non-zero — e.g. vim exits non-zero, editor missing but a wrapper returns error, or the editor process is killed.
Common situations: EDITOR pointing to a GUI app or editor that returns non-zero on save; editor failing to open the temp file; user killing the editor with a failing exit code; misquoted EDITOR with arguments not supported by the launcher.
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
- Editor exited with non-zero status
- Aborting due to empty branch name
- Aborting due to empty
- --ai cannot be combined with a resolve subcommand. For one…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/6054fc20d530904f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/reword2.rs:328
fn edit_commit_message(
repo: &gix::Repository,
context_lines: u32,
commit_details: CommitDetails,
editor_initial_message: &str,
current_message_for_comparison: &str,
) -> anyhow::Result<Option<String>> {
get_commit_message_from_editor_legacy(
repo,
context_lines,
commit_details,
editor_initial_message.to_owned(),
current_message_for_comparison,
ShowDiffInEditor::Unspecified,
)
.map_err(|err| {
if let Some(Code::EditorExitedWithNonZeroStatus) = err.downcast_ref::<but_error::Code>() {
anyhow::anyhow!("Editor exited with non-zero status")
} else {
err
}
})
}
pub enum RewordOperation {
Commit {
target: CommitId,
new_message: CommitMessageSource,
},
FormatCommit {
target: CommitId,
},
Branch {
target: FullName,
new_name: BranchNameSource,
},View on GitHub (pinned to 58e5313667)