{"record":{"id":"3e8ebdc25571595a","repo":"sinelaw/fresh","slug":"could-not-open-no-tokio-runtime-available-for-container","errorCode":null,"errorMessage":"could not open {}: no tokio runtime available for container fetch","messagePattern":"could not open (.+?): no tokio runtime available for container fetch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/app/file_open_orchestrators.rs","lineNumber":740,"sourceCode":"        ))\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,\n    ) -> anyhow::Result<BufferId> {\n        let runtime = self.tokio_runtime.as_ref().ok_or_else(|| {\n            anyhow::anyhow!(\n                \"could not open {}: no tokio runtime available for container fetch\",\n                container_path.display()\n            )\n        })?;\n\n        let spawner = self.authority().process_spawner.clone();\n        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 {","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/file_open_orchestrators.rs#L722-L758","documentation":"fetch_and_open_container_file runs `cat <path>` inside the container via tokio's block_on. It requires a tokio runtime stored on the app state; when self.tokio_runtime is None (headless/early startup or a build without the runtime initialized) the container fetch cannot be performed and this error is thrown.","triggerScenarios":"goto-definition resolves to a container-only file while the application was constructed without initializing tokio_runtime — e.g. remote/container mode entered before the async runtime was set up, or a code path that bypasses runtime initialization.","commonSituations":"Devcontainer workflows started through a code path that skips runtime setup; tests instantiating the app state manually without a runtime; regression after refactoring app initialization order.","solutions":["Ensure the tokio runtime is created during app startup before any remote/container authority is activated","Guard container-mode features behind runtime availability and disable them with a clear message when absent","In tests, construct the runtime (tokio::runtime::Runtime::new()) and inject it into app state","Audit initialization order after refactors so tokio_runtime is set before handle_goto_definition_response can fire"],"exampleFix":"// before\nlet buffer_id = self.fetch_and_open_container_file(container_path, uri.clone())?;\n// after\nif self.tokio_runtime.is_none() {\n    log::error!(\"container fetch unavailable: runtime not initialized\");\n    return Ok(self.active_buffer_id());\n}\nlet buffer_id = self.fetch_and_open_container_file(container_path, uri.clone())?;","handlingStrategy":"type-guard","validationCode":"if app.tokio_runtime.is_none() {\n    disable_container_features();\n}","typeGuard":"fn has_container_fetch(app: &App) -> bool {\n    app.tokio_runtime.is_some()\n}","tryCatchPattern":"match self.open_lsp_uri_target(&uri) {\n    Err(e) if e.to_string().contains(\"no tokio runtime\") => {\n        log::error!(\"container fetch disabled: runtime not initialized\");\n    }\n    other => other?,\n}","preventionTips":["Initialize the tokio runtime in app startup before enabling remote/container authorities","Add an initialization-order assertion/test that tokio_runtime is set in container mode","Gate container-only features on runtime availability at feature level, not deep in call paths","Re-check startup wiring after refactors to app state construction"],"tags":["tokio","async","devcontainer","initialization"],"backgroundTag":"internal-invariant-violation","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}