{"record":{"id":"db8325df76b6b936","repo":"nikivdev/code","slug":"editor-exited-with-status","errorCode":null,"errorMessage":"editor exited with status {}","messagePattern":"editor exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":15134,"sourceCode":"    // Create the file if it doesn't exist\n    if !note_file.exists() {\n        let template = format!(\n            \"# Session: {}\\n\\nSession ID: {}\\n\\n## Notes\\n\\n\",\n            session,\n            &session_id[..8.min(session_id.len())]\n        );\n        fs::write(&note_file, template)?;\n    }\n\n    // Open in $EDITOR\n    let editor = std::env::var(\"EDITOR\").unwrap_or_else(|_| \"vim\".to_string());\n    let status = Command::new(&editor)\n        .arg(&note_file)\n        .status()\n        .with_context(|| format!(\"failed to open editor: {}\", editor))?;\n\n    if !status.success() {\n        bail!(\"editor exited with status {}\", status);\n    }\n\n    Ok(())\n}\n\n/// Remove a saved session from tracking.\nfn remove_session(session: &str) -> Result<()> {\n    let mut index = load_index()?;\n\n    if index.sessions.remove(session).is_some() {\n        save_index(&index)?;\n        println!(\"Removed session '{}'\", session);\n\n        // Also remove notes if they exist\n        let notes_dir = get_notes_dir()?;\n        let note_file = notes_dir.join(format!(\"{}.md\", session));\n        if note_file.exists() {\n            fs::remove_file(&note_file)?;","sourceCodeStart":15116,"sourceCodeEnd":15152,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L15116-L15152","documentation":"Thrown after launching an external editor (from $EDITOR/$VISUAL or a default) to edit a notes file: the child process ran but returned a non-zero exit status. The error wraps the raw `status` so the developer sees the exit code. It means the editor itself failed, not that the file could not be opened (that produces the 'failed to open editor' context error instead).","triggerScenarios":"The notes-edit command spawns `Command::new(editor).arg(note_file).status()`, the editor binary launches but exits non-zero (user aborts in vim/:q!, editor writes fail, editor crashes, bad editor config).","commonSituations":"$EDITOR set to a broken wrapper script; vim/emacs exiting non-zero due to .vimrc errors; disk-full preventing the editor from saving; user pressing Ctrl-C inside the editor; headless environment launching a TUI editor that fails.","solutions":["Re-run the command and save/exit the editor normally with exit code 0","Check your $EDITOR/$VISUAL value and test it directly on the notes file to reproduce the non-zero exit","Fix editor config errors (vimrc, plugins) that cause non-zero exits","Ensure the disk has space and the editor can write the file"],"exampleFix":"// before\nEDITOR=\"vim -u brokenrc\" f ai notes edit\n// after\nEDITOR=vim f ai notes edit   # or fix the editor config so it exits 0","handlingStrategy":"try-catch","validationCode":"# shell: preflight the editor before invoking the command\ncommand -v \"${EDITOR%% *}\" >/dev/null || { echo \"EDITOR '$EDITOR' not found\"; exit 1; }\n: > /tmp/_editortest && \"$EDITOR\" /tmp/_editortest </dev/null >/dev/null 2>&1 || echo \"warning: $EDITOR exits non-zero\"","typeGuard":null,"tryCatchPattern":"// catch and surface the editor exit code distinctly\nmatch edit_notes(path) {\n    Err(e) if e.to_string().starts_with(\"editor exited with status\") => {\n        eprintln!(\"{} — fix $EDITOR or save and quit with :wq\", e);\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n    Ok(()) => Ok(()),\n}","preventionTips":["Set EDITOR/VISUAL to a known-good binary and test it exits 0 on :wq","Avoid wrapper scripts in EDITOR that can exit non-zero","Keep editor config (.vimrc etc.) free of failing plugins","Work with adequate disk space so editors can save"],"tags":["editor","process","exit-status","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"}