{"record":{"id":"426fab13c253d03d","repo":"astrid-runtime/astrid","slug":"editor-editor-exited-with-non-zero-status","errorCode":null,"errorMessage":"editor '{editor}' exited with non-zero status","messagePattern":"editor '(.+?)' exited with non-zero status","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/config.rs","lineNumber":75,"sourceCode":"    let home = astrid_core::dirs::AstridHome::resolve()\n        .map_err(|e| anyhow::anyhow!(\"Failed to resolve Astrid home: {e}\"))?;\n    let path = home.config_path();\n    if !path.exists() {\n        if let Some(parent) = path.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n        std::fs::write(&path, \"# Astrid runtime configuration\\n\")?;\n    }\n    let editor = std::env::var(\"EDITOR\")\n        .ok()\n        .or_else(|| std::env::var(\"VISUAL\").ok())\n        .unwrap_or_else(|| \"vi\".to_string());\n    let status = std::process::Command::new(&editor)\n        .arg(&path)\n        .status()\n        .map_err(|e| anyhow::anyhow!(\"Failed to launch '{editor}': {e}\"))?;\n    if !status.success() {\n        anyhow::bail!(\"editor '{editor}' exited with non-zero status\");\n    }\n    Ok(())\n}\n\n/// Show all config file paths that are checked.\n#[expect(clippy::unnecessary_wraps)]\npub(crate) fn show_paths() -> Result<()> {\n    let home = directories::BaseDirs::new().map(|d| d.home_dir().to_string_lossy().to_string());\n\n    let workspace = std::env::current_dir()\n        .ok()\n        .map(|p| p.to_string_lossy().to_string());\n    let astrid_home = std::env::var(\"ASTRID_HOME\").ok();\n\n    let paths = ResolvedConfig::config_paths_with_layout(\n        home.as_deref(),\n        astrid_home.as_deref(),\n        workspace.as_deref(),","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/config.rs#L57-L93","documentation":"`astrid config edit` launches the user's editor (from $EDITOR/$VISUAL, defaulting to vi) on the config file and requires a zero exit status. This error is thrown when the editor process ran but returned a non-zero code, meaning the editor itself reported a problem (user abort, unsavable file, bad editor config).","triggerScenarios":"Running `astrid config edit` (edit_config) where the spawned editor command exits with status != 0 — e.g. the user quits vi with :cq, nano fails to write, or the editor errors on the file.","commonSituations":"EDITOR set to a GUI app or a program that doesn't accept a file argument; user intentionally aborts in vi with :cq; editor lacks write permission on the config path; misconfigured editor plugin failing at startup.","solutions":["Check what $EDITOR/$VISUAL is set to and pick a terminal editor that exits 0 on save: export EDITOR=vim (or nano) and retry.","Open the config file manually at the printed path, edit it, and save.","Check for write permission on the config file and fix ownership/permissions if the editor failed to save.","If the editor exit is intentional-abort behavior, ignore the error — the config was not changed."],"exampleFix":"// before\n$ EDITOR=code astrid config edit  # GUI editor returns non-zero in CI\n// after\n$ export EDITOR=vim\n$ astrid config edit  # OK","handlingStrategy":"validation","validationCode":"// Validate the editor before launching it\nfn editor_ok(editor: &str) -> bool {\n    match std::process::Command::new(editor).arg(\"--version\").status() {\n        Ok(s) => s.success(),\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"let status = std::process::Command::new(&editor).arg(&path).status()\n    .map_err(|e| anyhow::anyhow!(\"Failed to launch '{editor}': {e}\"))?;\nif !status.success() {\n    eprintln!(\"editor '{editor}' exited with {} (config unchanged); set $EDITOR to a terminal editor and retry\",\n        status.code().unwrap_or(-1));\n    return Ok(()); // treat abort as no-op instead of a hard error\n}","preventionTips":["Set $EDITOR/$VISUAL to a terminal editor (vim, nano) that accepts a file path and exits 0 on save.","In scripts/CI, prefer `astrid config set key value` over interactive editing.","Ensure the config file is writable by the user running the editor.","Remember vi's :cq exits non-zero by design — use :wq or :q! instead."],"tags":["editor","cli","config","process"],"backgroundTag":"process-exited-nonzero","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}