{"record":{"id":"c144a1947103eb71","repo":"astrid-runtime/astrid","slug":"failed-to-launch-editor-e","errorCode":null,"errorMessage":"Failed to launch '{editor}': {e}","messagePattern":"Failed to launch '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/config.rs","lineNumber":73,"sourceCode":"/// file if missing so the editor opens on a real path.\npub(crate) fn edit_config() -> Result<()> {\n    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(),","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/config.rs#L55-L91","documentation":"Thrown by `edit_config` when spawning `$EDITOR`/`$VISUAL` (default `vi`) via `std::process::Command::status()` fails, i.e. the process could not be launched at all. This is distinct from the editor exiting non-zero (that produces 'editor ... exited with non-zero status'). Typical cause is the editor binary not existing or not being executable.","triggerScenarios":"Running `astrid config edit` with EDITOR set to a nonexistent program, an editor not on PATH, a non-executable file, or a GUI editor invoked from a headless environment where its launch prerequisites are missing.","commonSituations":"EDITOR='code --wait' in a container without code installed; EDITOR set to a shell alias (aliases aren't resolved by Command::new); EDITOR contains arguments that the resolver doesn't split.","solutions":["Verify the editor exists and is executable: `command -v \"$EDITOR\"`.","Set EDITOR/VISUAL to a plain binary name on PATH, e.g. `export EDITOR=vim` (avoid aliases or argument strings).","Install the configured editor or pick one present in the environment (`export VISUAL=vi`).","Check the wrapped {e} for NotFound/PermissionDenied and fix PATH or chmod +x accordingly."],"exampleFix":"// before (shell)\nexport EDITOR=\"code --wait\"   # fails in headless env\nastrid config edit\n// after (shell)\nexport VISUAL=vi\nexport EDITOR=vi\nastrid config edit","handlingStrategy":"validation","validationCode":"let editor = std::env::var(\"EDITOR\").or_else(|_| std::env::var(\"VISUAL\")).unwrap_or_else(|_| \"vi\".into());\nif which::which(&editor).is_err() {\n    eprintln!(\"EDITOR '{editor}' not found on PATH; falling back to vi\");\n}","typeGuard":null,"tryCatchPattern":"match Command::new(&editor).arg(&path).status() {\n    Err(e) => eprintln!(\"cannot launch '{editor}': {e}; is it installed and on PATH?\"),\n    Ok(s) if !s.success() => eprintln!(\"editor exited with {s}\"),\n    Ok(_) => {},\n}","preventionTips":["Set EDITOR/VISUAL to a plain binary name available on PATH (vim, vi, nano).","Never point EDITOR at a shell alias or a string with arguments unless the CLI splits them.","In containers/headless servers, export VISUAL=vi since GUI editors cannot launch.","Verify `command -v \"$EDITOR\"` succeeds in provisioning scripts."],"tags":["cli","editor","process-spawn","environment"],"backgroundTag":"command-not-found","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}