{"record":{"id":"753124a1eafc8383","repo":"sinelaw/fresh","slug":"could-not-open-from-container","errorCode":null,"errorMessage":"could not open {} from container: {}","messagePattern":"could not open (.+?) from container: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/app/file_open_orchestrators.rs","lineNumber":765,"sourceCode":"        let path_arg = container_path.to_string_lossy().into_owned();\n        let result = runtime\n            .block_on(spawner.spawn(\"cat\".into(), vec![path_arg], None))\n            .map_err(|e| {\n                anyhow::anyhow!(\n                    \"could not open {} from container: {}\",\n                    container_path.display(),\n                    e\n                )\n            })?;\n\n        if result.exit_code != 0 {\n            let first_stderr_line = result\n                .stderr\n                .lines()\n                .next()\n                .unwrap_or(\"(no error message)\")\n                .trim();\n            anyhow::bail!(\n                \"could not open {} from container: {}\",\n                container_path.display(),\n                first_stderr_line\n            );\n        }\n\n        self.open_container_only_file(container_path, uri, result.stdout.into_bytes())\n    }\n\n    /// Build a buffer from already-fetched container content. The\n    /// buffer's `file_path` is the in-container path (so further LSP\n    /// requests carry the right URI) and the buffer is read-only —\n    /// there is no host writeback path for files that exist only\n    /// inside the container. LSP stays enabled so a follow-up\n    /// goto-def from the fetched buffer works.\n    pub(crate) fn open_container_only_file(\n        &mut self,\n        container_path: std::path::PathBuf,","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/file_open_orchestrators.rs#L747-L783","documentation":"fetch_and_open_container_file runs a command (e.g. docker/kubectl exec cat) to extract a file from a container; when that command exits with an error, the first line of its stderr is surfaced in this bail. It means the container-side read of the requested path failed.","triggerScenarios":"open_lsp_uri_target resolving a container:// URI where the exec command returns non-zero status — file missing in the container, permission denied, container not running, or the exec binary is unavailable.","commonSituations":"LSP sends a URI for a file inside a container that was restarted or removed; typo'd container path; container image lacks the file; docker exec fails due to stopped container.","solutions":["Check the full stderr to see whether the file exists in the container (ls the path via exec).","Verify the container is running and the exec command/binary name is correct in the URI.","Correct the container path in the URI and retry opening the file."],"exampleFix":"// before\nlet uri = \"container://myapp/etc/hosts\"; // file missing\n// after\n// verify first: docker exec myapp cat /etc/hosts\nlet uri = \"container://myapp//etc/hosts\"; // corrected absolute path","handlingStrategy":"try-catch","validationCode":"// verify the file exists in the container first\n// docker exec <container> test -f <path> && echo ok","typeGuard":null,"tryCatchPattern":"match editor_open_target(uri) { Err(e) if e.to_string().contains(\"from container\") => show_message(format!(\"container read failed: {e}\")), r => r }","preventionTips":["Confirm the container is running before resolving container:// URIs","Use absolute paths inside the container","Test the exec command manually before wiring it into URIs"],"tags":["container","file-open","remote"],"backgroundTag":"file-read-failed","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"}