{"record":{"id":"a9f5b7d085fdc37d","repo":"nikivdev/code","slug":"failed-to-open","errorCode":null,"errorMessage":"failed to open {}","messagePattern":"failed to open (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/deps.rs","lineNumber":1200,"sourceCode":"    if let Ok(repo_ref) = repos::parse_github_repo(url) {\n        if root_path.join(repo_ref.owner).join(repo_ref.repo).exists() {\n            return true;\n        }\n    }\n    false\n}\n\nfn open_in_zed(path: &Path) -> Result<()> {\n    let status = Command::new(\"open\")\n        .args([\"-a\", \"/Applications/Zed.app\"])\n        .arg(path)\n        .status()\n        .context(\"failed to launch Zed\")?;\n\n    if status.success() {\n        Ok(())\n    } else {\n        bail!(\"failed to open {}\", path.display());\n    }\n}\n\nfn path_relative(root: &Path, path: &Path) -> String {\n    path.strip_prefix(root)\n        .unwrap_or(path)\n        .display()\n        .to_string()\n}\n\nfn is_project_root(root: &Path, candidate: &Path) -> bool {\n    let root = root.canonicalize().unwrap_or_else(|_| root.to_path_buf());\n    let candidate = candidate\n        .canonicalize()\n        .unwrap_or_else(|_| candidate.to_path_buf());\n    root == candidate\n}\n","sourceCodeStart":1182,"sourceCodeEnd":1218,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/deps.rs#L1182-L1218","documentation":"Raised by the Zed-open helper in src/deps.rs:1200 after spawning the Zed editor process successfully but with a non-zero exit status. The path could not be opened, and the tool reports the path that failed via `path.display()`. Distinct from the `failed to launch Zed` context error, which fires when the binary itself cannot be spawned.","triggerScenarios":"Calling the open-in-Zed action when Zed exits non-zero for the given path: e.g. the path does not exist or is not readable, Zed is not fully installed/licensed CLI handshake fails, or the user closes Zed with an error.","commonSituations":"Passing a file path that was deleted or renamed, running on a headless box with no display so Zed cannot start, or a stale `zed` shim on PATH pointing to an uninstall.","solutions":["Verify the path exists and is readable: ls the exact path printed in the message","Run `zed <path>` manually to see Zed's own error output","Reinstall or repair the Zed CLI (`zed --version`) and ensure a display/GUI session is available","Fall back to $EDITOR if Zed keeps failing"],"exampleFix":"// before\nf open deps/foo/src/lib.rs   # path deleted by a rebuild\nerror: failed to open deps/foo/src/lib.rs\n// after\nls deps/foo/src/lib.rs && f open deps/foo/src/lib.rs","handlingStrategy":"fallback","validationCode":"let target = Path::new(path);\nif !target.exists() {\n    eprintln!(\"cannot open: {} does not exist\", target.display());\n    return Ok(());\n}","typeGuard":"fn openable_in_editor(path: &Path) -> bool {\n    path.exists() && std::fs::metadata(path).map(|m| !m.is_dir() || path.is_dir()).is_ok()\n}","tryCatchPattern":"if let Err(e) = open_in_zed(path) {\n    let msg = e.to_string();\n    if msg.starts_with(\"failed to open\") || msg.contains(\"failed to launch Zed\") {\n        open_with_editor_env(path)?; // fallback to $EDITOR\n    } else { return Err(e); }\n}","preventionTips":["Confirm the path exists right before opening (builds may delete/rename files)","Set EDITOR as a reliable fallback","Ensure a GUI session exists when using Zed on remote machines","Verify `zed --version` works in the target environment"],"tags":["editor","subprocess","zed"],"backgroundTag":"editor-launch-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}