nikivdev/code · error
Editor exited with status
Error message
Editor exited with status {:?} What it means
This error is raised by the edit_agent flow after launching the user's configured editor as a child process. The editor was spawned successfully but exited with a non-zero status code, meaning it terminated abnormally (crash, bad exit, user abort). The library surfaces the raw exit code so the developer can diagnose which editor and why.
Solutions
- Re-run the command and watch the inherited editor output for its error message
- Verify $EDITOR/$VISUAL points to a working editor binary (run it directly with the same file)
- Ensure the command runs in an interactive TTY if the editor requires one
- Check file permissions on the file being edited
Example fix
// before (CI, no TTY) EDITOR=vim f edit-agent // after EDITOR=vi f edit-agent # or run inside an interactive terminal / use a non-TTY editor like `sed -i`
Defensive patterns
Strategy: try-catch
Validate before calling
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".into());
if which::which(&editor).is_err() {
eprintln!("editor '{}' not found on PATH", editor);
} Type guard
fn editor_exists(editor: &str) -> bool {
std::process::Command::new(editor).arg("--version").output().map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match edit_agent(...) {
Ok(()) => {},
Err(e) if e.to_string().contains("Editor exited with status") => {
eprintln!("editor failed: {e:#}; check $EDITOR and run in a TTY");
}
Err(e) => return Err(e),
} Prevention
- Point EDITOR/VISUAL at a real binary, not a shell alias or function
- Run the command in an interactive TTY when using full-screen editors
- Test the editor manually on the target file before automating
When it happens
Trigger: Calling edit_agent opens $EDITOR/$VISUAL (or a configured editor) via Command .status(); the child process returns a non-zero exit code, e.g. the editor crashed, printed an error and quit, or the user killed it.
Common situations: EDITOR set to a broken shell alias or nonexistent wrapper script; editor fails to render the agent file (permission issues on the temp file); terminal incompatibilities (e.g. vi in a non-TTY environment); user force-quits the editor.
Related errors
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/e860df22d0257342.
Report an issue: GitHub.
Appendix: source
Thrown at src/hive.rs:411
Ok(path)
}
/// Edit an agent spec file
pub fn edit_agent(name: &str) -> Result<()> {
let (path, _source) =
find_agent_spec(name).ok_or_else(|| anyhow::anyhow!("Agent '{}' not found", name))?;
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vim".to_string());
let status = Command::new(&editor)
.arg(&path)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.context(format!("Failed to open editor '{}'", editor))?;
if !status.success() {
anyhow::bail!("Editor exited with status {:?}", status.code());
}
Ok(())
}
/// List agents in a formatted table
pub fn list_agents(project_agents: &[AgentConfig]) {
let agents = discover_agents(project_agents);
if agents.is_empty() {
println!("No agents found.");
println!("\nCreate one with: f hive new <name>");
return;
}
println!("{:<20} {:<10} {}", "NAME", "SOURCE", "DESCRIPTION");
println!("{}", "-".repeat(60));
View on GitHub (pinned to a747e741ae)