{"record":{"id":"6054fc20d530904f","repo":"gitbutlerapp/gitbutler","slug":"editor-exited-with-non-zero-status","errorCode":null,"errorMessage":"Editor exited with non-zero status","messagePattern":"Editor exited with non-zero status","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/reword2.rs","lineNumber":328,"sourceCode":"\nfn edit_commit_message(\n    repo: &gix::Repository,\n    context_lines: u32,\n    commit_details: CommitDetails,\n    editor_initial_message: &str,\n    current_message_for_comparison: &str,\n) -> anyhow::Result<Option<String>> {\n    get_commit_message_from_editor_legacy(\n        repo,\n        context_lines,\n        commit_details,\n        editor_initial_message.to_owned(),\n        current_message_for_comparison,\n        ShowDiffInEditor::Unspecified,\n    )\n    .map_err(|err| {\n        if let Some(Code::EditorExitedWithNonZeroStatus) = err.downcast_ref::<but_error::Code>() {\n            anyhow::anyhow!(\"Editor exited with non-zero status\")\n        } else {\n            err\n        }\n    })\n}\n\npub enum RewordOperation {\n    Commit {\n        target: CommitId,\n        new_message: CommitMessageSource,\n    },\n    FormatCommit {\n        target: CommitId,\n    },\n    Branch {\n        target: FullName,\n        new_name: BranchNameSource,\n    },","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/reword2.rs#L310-L346","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nEDITOR=\"code\" but reword <commit>   # VS Code exits without --wait\n// after\nexport EDITOR=\"code --wait\"\nbut reword <commit>","handlingStrategy":"try-catch","validationCode":"// ensure the editor exits 0 on save\necho test > /tmp/editcheck && \"$EDITOR\" /tmp/editcheck && rm /tmp/editcheck || echo 'Editor broken'","typeGuard":null,"tryCatchPattern":"match but reword <commit>:\n  on failure matching 'Editor exited with non-zero status':\n    retry with EDITOR=vim (or pass message directly) and surface editor stderr","preventionTips":["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"],"tags":["editor","cli","external-process"],"backgroundTag":"git-command-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}