{"record":{"id":"3c3f4592221859e3","repo":"denisidoro/navi","slug":"could-not-open-file-in-external-editor","errorCode":null,"errorMessage":"Could not open file in external editor","messagePattern":"Could not open file in external editor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/commands/core/actor.rs","lineNumber":224,"sourceCode":"pub fn act(\n    extractions: Result<(&str, Item)>,\n    files: Vec<String>,\n    variables: Option<VariableMap>,\n) -> Result<()> {\n    let (\n        key,\n        Item {\n            tags,\n            comment,\n            snippet,\n            file_index,\n            ..\n        },\n    ) = extractions.unwrap();\n\n    if key == \"ctrl-o\" {\n        edit::edit_file(Path::new(&files[file_index.expect(\"No files found\")]))\n            .expect(\"Could not open file in external editor\");\n        return Ok(());\n    }\n\n    env_var::set(env_var::PREVIEW_INITIAL_SNIPPET, &snippet);\n    env_var::set(env_var::PREVIEW_TAGS, &tags);\n    env_var::set(env_var::PREVIEW_COMMENT, comment);\n\n    let interpolated_snippet = {\n        let mut s = replace_variables_from_snippet(\n            &snippet,\n            &tags,\n            variables.expect(\"No variables received from finder\"),\n        )\n        .context(\"Failed to replace variables from snippet\")?;\n        s = with_absolute_path(s);\n        s = deser::with_new_lines(s);\n        s\n    };","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/denisidoro/navi/blob/f7330b9ad5bd95b7d1a3c96d00e0a77deb589147/src/commands/core/actor.rs#L206-L242","documentation":"Raised in `act` in src/commands/core/actor.rs (src/commands/core/actor.rs:224) via `.expect(\"Could not open file in external editor\")` when `edit::edit_file` fails to spawn or run the external editor on the selected file. The file index was valid, but launching the editor errored.","triggerScenarios":"Pressing ctrl-o on a valid file selection when the external editor cannot be launched — `$EDITOR`/`$VISUAL` unset or pointing at a nonexistent binary, the editor exits non-zero, or the file path is inaccessible.","commonSituations":"Minimal Docker/CI environments with no editor configured; EDITOR set to a GUI app unavailable in the current session; typo in the EDITOR variable; read-only or deleted target file.","solutions":["Set `$EDITOR` (or `$VISUAL`) to a working editor, e.g. `export EDITOR=vim`","Verify the editor binary exists on PATH (`which $EDITOR`)","Check the target file exists and is writable","Run in an environment where the configured editor can actually start (TTY available)"],"exampleFix":"// before (shell)\n./tool  # EDITOR unset -> panic on ctrl-o\n// after (shell)\nexport EDITOR=vim\n./tool","handlingStrategy":"validation","validationCode":"let editor_ok = std::env::var(\"EDITOR\")\n    .or_else(|_| std::env::var(\"VISUAL\"))\n    .map(|e| which::which(&e).is_ok())\n    .unwrap_or(false);\nif !editor_ok { eprintln!(\"Set EDITOR to a working editor before using ctrl-o\"); }","typeGuard":null,"tryCatchPattern":"let status = child.wait()?;\nif !status.success() && stderr.contains(\"Could not open file in external editor\") {\n    eprintln!(\"Check $EDITOR/$VISUAL point to an installed, runnable editor.\");\n}","preventionTips":["Always export EDITOR (or VISUAL) in shell profiles, including containers/CI images","Verify the editor binary exists on PATH after changing it","Ensure the target file exists and is writable before opening"],"tags":["editor","env-var","panic","process"],"backgroundTag":"editor-not-configured","analyzedSha":"f7330b9ad5bd95b7d1a3c96d00e0a77deb589147","analyzedAt":"2026-09-03T13:58:22.429Z","contentChangedAt":"2026-09-03T13:58:22.429Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}