{"record":{"id":"451c0ed223746b28","repo":"sinelaw/fresh","slug":"could-not-open-file-not-found","errorCode":null,"errorMessage":"could not open {}: file not found","messagePattern":"could not open (.+?): file not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/app/file_open_orchestrators.rs","lineNumber":719,"sourceCode":"        // skip straight to the error case.\n        if translation.is_some() {\n            // The container-side path is the URI's raw path. Calling\n            // `to_host_path` with `None` returns the wire-side path\n            // verbatim (no translation applied) — exactly what we\n            // need for `cat <path>` inside the container.\n            let container_path = uri.to_host_path(None).ok_or_else(|| {\n                anyhow::anyhow!(\"URI is not a file path (container-side decode failed)\")\n            })?;\n            let buffer_id = self.fetch_and_open_container_file(container_path, uri.clone())?;\n            // Match `open_file`'s focus behaviour so the cursor\n            // assertion in callers (goto-def's `MoveCursor` event)\n            // applies to the right buffer.\n            self.set_active_buffer(buffer_id);\n            return Ok(buffer_id);\n        }\n\n        // Case 3: nothing we can open.\n        Err(anyhow::anyhow!(\n            \"could not open {}: file not found\",\n            host_path.display()\n        ))\n    }\n\n    /// Run `cat <container_path>` through the active authority's\n    /// process spawner and open the result as a read-only buffer\n    /// tagged with the wire URI. Helper for [`Self::open_lsp_uri_target`].\n    ///\n    /// On `cat` exit-code 0 the bytes become the buffer's contents.\n    /// On any error (no tokio runtime, spawner failure, non-zero\n    /// exit) we return `Err` with a message that includes the\n    /// container path and stderr's first line — enough for the\n    /// caller's status-line surface.\n    fn fetch_and_open_container_file(\n        &mut self,\n        container_path: std::path::PathBuf,\n        uri: crate::app::types::LspUri,","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/file_open_orchestrators.rs#L701-L737","documentation":"Final fallback of open_lsp_uri_target: the URI decoded to a host path but the file is neither reachable on the host filesystem nor fetchable from the container, so no buffer can be opened and this 'file not found' error is returned with the decoded path in the message.","triggerScenarios":"goto-definition targets a path that does not exist on the host (and no container translation applies), e.g. the symbol lives in a dependency's source that isn't checked out, or the workspace mounted in the container differs from the host checkout.","commonSituations":"Jumping to definition into a crate/dependency whose source isn't downloaded (no cargo registry sources, node_modules absent); stale LSP index pointing at deleted files; container path vs host path mismatch.","solutions":["Verify the decoded path exists on disk; if not, fetch dependencies (cargo fetch / npm install) so sources exist","Check the authority's path_translation mapping matches the container's layout","Reload the LSP workspace if the file was recently created or moved (stale index)","Sync the file into the container/host so both sides see it"],"exampleFix":"// before\nlet buffer_id = self.open_lsp_uri_target(&uri)?;\n// after\nmatch self.open_lsp_uri_target(&uri) {\n    Ok(id) => Ok(id),\n    Err(e) if e.to_string().contains(\"file not found\") => {\n        log::warn!(\"definition target missing on disk; prompting fetch\");\n        self.prompt_fetch_missing_source(&uri)\n    }\n    Err(e) => Err(e),\n}","handlingStrategy":"fallback","validationCode":"let host = uri.to_host_path(translation.as_ref());\nif let Some(p) = &host && !p.exists() && translation.is_none() {\n    // surface 'file not found' to the user instead of erroring hard\n}","typeGuard":"fn openable_on_host(uri: &LspUri, t: Option<&PathTranslation>) -> bool {\n    uri.to_host_path(t).map(|p| p.exists()).unwrap_or(false)\n}","tryCatchPattern":"match self.open_lsp_uri_target(&uri) {\n    Err(e) if e.to_string().contains(\"file not found\") => {\n        self.show_message(\"Definition source not on disk — fetch dependencies or sync the file.\");\n    }\n    other => other?,\n}","preventionTips":["Ensure dependency sources are fetched (cargo fetch, npm install) before navigating into them","Keep host and container checkouts in sync with the authority's path_translation mapping","Reload the LSP workspace after files are created/moved to avoid stale definition targets","Stat the decoded path before opening and offer a fetch prompt when missing"],"tags":["file-not-found","lsp","goto-definition"],"backgroundTag":"file-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}