{"record":{"id":"14f2cda1d0d62b3e","repo":"Hmbown/CodeWhale","slug":"editor-editor-exited-with-status","errorCode":null,"errorMessage":"editor {editor:?} exited with {status}","messagePattern":"editor (.+?) exited with (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":4642,"sourceCode":"            }\n            Ok(())\n        }\n        ConfigCommand::Path => {\n            println!(\"{}\", store.path().display());\n            Ok(())\n        }\n        ConfigCommand::Edit => {\n            let path = store.path().to_path_buf();\n            println!(\"{}\", path.display());\n            let editor = std::env::var(\"VISUAL\")\n                .or_else(|_| std::env::var(\"EDITOR\"))\n                .unwrap_or_else(|_| \"vi\".to_string());\n            let status = Command::new(&editor)\n                .arg(&path)\n                .status()\n                .with_context(|| format!(\"failed to launch editor {editor:?}\"))?;\n            if !status.success() {\n                bail!(\"editor {editor:?} exited with {status}\");\n            }\n            Ok(())\n        }\n        ConfigCommand::Doctor => run_config_doctor(store),\n        ConfigCommand::Dump => {\n            if !per_run_overrides.is_empty() {\n                println!(\n                    \"# {} per-run --set override(s), not saved\",\n                    per_run_overrides.len()\n                );\n            }\n            println!(\"# {}\", store.path().display());\n            print!(\n                \"{}\",\n                toml::to_string_pretty(&store.config.redacted_toml_value())?\n            );\n            Ok(())\n        }","sourceCodeStart":4624,"sourceCodeEnd":4660,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/lib.rs#L4624-L4660","documentation":"When running the config editor subcommand (e.g. `codewhale config edit`), the CLI spawns $VISUAL/$EDITOR (defaulting to vi) on the config file and checks its exit status. If the editor process terminates with a nonzero status, the command reports the editor and its status via this error.","triggerScenarios":"The editor binary launched successfully (status() returned Ok) but exited with status.success() == false — e.g. the editor crashed, the file failed validation inside the editor, or a save failed.","commonSituations":"Misconfigured EDITOR pointing to a wrapper script that fails; editor refusing to open an unreadable file path; exiting vi/vim with :cq or a forced quit with an error; disk-full or permission errors inside the editor.","solutions":["Re-run and check the editor's own output for its error message.","Verify $VISUAL/$EDITOR points to a working editor: `echo $EDITOR` and try opening the file directly.","Fall back to a known-good editor: `EDITOR=vi codewhale config edit` (or nano).","Edit the config file manually with any editor instead of the subcommand."],"exampleFix":"// before\n$EDITOR='my-broken-wrapper' codewhale config edit\n// after\nEDITOR=vim codewhale config edit","handlingStrategy":"try-catch","validationCode":"let editor = std::env::var(\"VISUAL\").or_else(|_| std::env::var(\"EDITOR\")).unwrap_or_else(|_| \"vi\".into());\nif which::which(&editor).is_err() {\n    eprintln!(\"editor '{editor}' not found; set $EDITOR to a working editor\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = run_config_edit() {\n    if let Some(status) = extract_editor_status(&e) {\n        eprintln!(\"editor failed with {status}; fix the file manually or choose another $EDITOR\");\n    } else { return Err(e); }\n}","preventionTips":["Verify $VISUAL/$EDITOR points to a real binary before invoking config edit.","Avoid editors/wrappers that exit nonzero on normal quits (e.g. exit codes from :cq in vim).","Test the editor on a scratch file: `$EDITOR /tmp/x` should exit 0."],"tags":["cli","editor","process"],"backgroundTag":"command-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}