GitoxideLabs/gitoxide · error · anyhow::Error
Editor exited with
Error message
Editor {editor_display} exited with {status} What it means
The editor helper spawns an external editor process (e.g. for commit messages or interactive input), waits for it, and throws this error if the editor exits with a non-zero status. A launch or wait failure is wrapped in separate context errors; this specific error is the editor's own non-success exit code.
Solutions
- Check the editor's stderr output to see why it failed
- Verify $GIT_EDITOR / $EDITOR / core.editor points to a working editor
- Test the editor command manually in a terminal with a sample file
- Fix or replace the editor wrapper script that exits non-zero
Example fix
// before (env) GIT_EDITOR=/usr/bin/broken-editor // after (env) GIT_EDITOR=/usr/bin/vim
Defensive patterns
Strategy: try-catch
Validate before calling
// verify editor is executable before spawning
let ok = std::process::Command::new("sh")
.arg("-c")
.arg(format!("command -v {} >/dev/null", editor))
.status()
.map(|s| s.success())
.unwrap_or(false);
if !ok { eprintln!("editor '{editor}' not available"); } Try / catch
match edit(&editor, &paths) {
Err(e) if e.to_string().contains("exited with") => {
eprintln!("editor failed or was aborted: {e}");
std::process::exit(1);
}
other => other?,
} Prevention
- Set GIT_EDITOR / EDITOR to a known-working program
- Test the editor command manually before relying on it in scripts
- Check editor stderr to diagnose non-zero exits
- Avoid editor wrapper scripts that exit non-zero on normal saves
When it happens
Trigger: Calling the function in gitoxide-core/src/repository/editor.rs with a configured editor program that runs but returns a non-zero exit status — e.g. the editor crashed, the user aborted a save, or the editor wrote errors to stderr.
Common situations: Core.editor / GIT_EDITOR / EDITOR misconfiguration pointing at a broken or missing-editor wrapper script; user aborts in the editor (some editors exit non-zero on abort); terminal/shell wrapper returning errors.
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
- Git editor exited with
- external diff exited with
- diff pager exited with
- prepared splits have an editor
- prepared commits have an editor
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/98477c6766f1fc17.
Report an issue: GitHub.
Appendix: source
Thrown at gitoxide-core/src/repository/editor.rs:18
use std::path::PathBuf;
use anyhow::{Context, Result, bail};
pub fn function(repo: gix::Repository, paths: Vec<PathBuf>) -> Result<()> {
let editor = repo
.editor_command()
.context("Could not prepare editor")?
.context("No editor is configured and the terminal is not capable of running one")?;
let editor_display = editor.command.to_string_lossy().into_owned();
let status = editor
.args(paths)
.spawn()
.with_context(|| format!("Could not launch editor {editor_display}"))?
.wait()
.with_context(|| format!("Could not wait for editor {editor_display}"))?;
if !status.success() {
bail!("Editor {editor_display} exited with {status}");
}
Ok(())
}
View on GitHub (pinned to e73179060b)