{"record":{"id":"e860df22d0257342","repo":"nikivdev/code","slug":"editor-exited-with-status-e860df","errorCode":null,"errorMessage":"Editor exited with status {:?}","messagePattern":"Editor exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hive.rs","lineNumber":411,"sourceCode":"    Ok(path)\n}\n\n/// Edit an agent spec file\npub fn edit_agent(name: &str) -> Result<()> {\n    let (path, _source) =\n        find_agent_spec(name).ok_or_else(|| anyhow::anyhow!(\"Agent '{}' not found\", name))?;\n\n    let editor = std::env::var(\"EDITOR\").unwrap_or_else(|_| \"vim\".to_string());\n    let status = Command::new(&editor)\n        .arg(&path)\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .context(format!(\"Failed to open editor '{}'\", editor))?;\n\n    if !status.success() {\n        anyhow::bail!(\"Editor exited with status {:?}\", status.code());\n    }\n\n    Ok(())\n}\n\n/// List agents in a formatted table\npub fn list_agents(project_agents: &[AgentConfig]) {\n    let agents = discover_agents(project_agents);\n\n    if agents.is_empty() {\n        println!(\"No agents found.\");\n        println!(\"\\nCreate one with: f hive new <name>\");\n        return;\n    }\n\n    println!(\"{:<20} {:<10} {}\", \"NAME\", \"SOURCE\", \"DESCRIPTION\");\n    println!(\"{}\", \"-\".repeat(60));\n","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/hive.rs#L393-L429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (CI, no TTY)\nEDITOR=vim f edit-agent\n// after\nEDITOR=vi f edit-agent   # or run inside an interactive terminal / use a non-TTY editor like `sed -i`","handlingStrategy":"try-catch","validationCode":"let editor = std::env::var(\"EDITOR\").unwrap_or_else(|_| \"vi\".into());\nif which::which(&editor).is_err() {\n    eprintln!(\"editor '{}' not found on PATH\", editor);\n}","typeGuard":"fn editor_exists(editor: &str) -> bool {\n    std::process::Command::new(editor).arg(\"--version\").output().map(|o| o.status.success()).unwrap_or(false)\n}","tryCatchPattern":"match edit_agent(...) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"Editor exited with status\") => {\n        eprintln!(\"editor failed: {e:#}; check $EDITOR and run in a TTY\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["editor","process-exit","cli"],"backgroundTag":"editor-nonzero-exit","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}