{"record":{"id":"6a7f1a0e7bdede33","repo":"unicity-aos/aos-ce","slug":"cannot-construct-the-bundled-runtime-path-error","errorCode":null,"errorMessage":"cannot construct the bundled runtime PATH: {error}","messagePattern":"cannot construct the bundled runtime PATH: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/unicity-aos-bootstrap/src/lib.rs","lineNumber":424,"sourceCode":"        if let Some(workspace) = workspace {\n            args.push(OsString::from(\"--workspace\"));\n            args.push(workspace.as_os_str().to_owned());\n        }\n        if verbose {\n            args.push(OsString::from(\"--verbose\"));\n        }\n        let mut command = self.runtime_executable_command(&daemon_binary, args)?;\n        command.env(\"ASTRID_DAEMON_LOG_TARGET\", \"stderr\");\n        Ok(command)\n    }\n\n    fn runtime_child_path(runtime_bin: &Path, host_path: Option<OsString>) -> io::Result<OsString> {\n        let mut child_path = vec![runtime_bin.to_path_buf()];\n        if let Some(host_path) = host_path {\n            child_path.extend(std::env::split_paths(&host_path));\n        }\n        std::env::join_paths(child_path).map_err(|error| {\n            io::Error::new(\n                io::ErrorKind::InvalidInput,\n                format!(\"cannot construct the bundled runtime PATH: {error}\"),\n            )\n        })\n    }\n\n    /// Spawn the bundled runtime with its AOS-owned runtime home.\n    ///\n    /// # Errors\n    /// Returns an error when the bundled executable is absent or cannot start.\n    pub fn spawn_runtime(&self) -> io::Result<Child> {\n        self.spawn_runtime_with_args(std::iter::empty::<&OsStr>())\n    }\n\n    /// Spawn the bundled runtime with runtime CLI arguments.\n    ///\n    /// This path uses the runtime's normal local operator credentials. The\n    /// runtime home remains scoped to this AOS installation.","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/crates/unicity-aos-bootstrap/src/lib.rs#L406-L442","documentation":"runtime_child_path joins the bundled runtime bin directory with the host PATH via std::env::join_paths and wraps any join failure (invalid UTF-8/empty path entries, etc.) in an InvalidInput error formatted as \"cannot construct the bundled runtime PATH: {error}\". It exists because the child process must receive a PATH that prefers bundled tools.","triggerScenarios":"Calling runtime_child_path when either the runtime_bin path or an entry inside the host PATH cannot be joined — most commonly an empty path element or a path containing characters the platform disallows in PATH entries (join_paths returns JoinPathsError).","commonSituations":"A malformed host PATH containing empty entries (\"::\") or NUL bytes; inheriting PATH from a broken container/shell init; passing an empty runtime_bin PathBuf.","solutions":["Fix the host PATH environment variable: remove empty entries and invalid characters, then relaunch.","Sanitize the host PATH before calling (filter out empty/non-UTF-8 components) instead of passing it through.","Ensure runtime_bin is a valid non-empty directory path."],"exampleFix":"// before\nlet host_path = std::env::var_os(\"PATH\"); // contains empty entry\nlet p = runtime_child_path(&runtime_bin, host_path)?;\n// after\nlet host_path = std::env::var_os(\"PATH\")\n    .map(|p| std::env::split_paths(&p).filter(|c| !c.as_os_str().is_empty()).collect::<Vec<_>>())\n    .map(|v| std::env::join_paths(v).expect(\"sanitized PATH joins\"));\nlet p = runtime_child_path(&runtime_bin, host_path)?;","handlingStrategy":"validation","validationCode":"fn sanitized_host_path() -> Option<OsString> {\n    std::env::var_os(\"PATH\").map(|p| {\n        std::env::join_paths(\n            std::env::split_paths(&p).filter(|c| !c.as_os_str().is_empty()),\n        ).expect(\"sanitized PATH should join\")\n    })\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"cannot construct the bundled runtime PATH\") => {\n        eprintln!(\"host PATH is malformed (empty entries or invalid characters); fix PATH and relaunch\");\n    }\n    other => other?,\n}","preventionTips":["Audit PATH in container images and shell init for empty entries (::) — they are valid to split but rejected on join in some cases; sanitize anyway.","Never inject NUL bytes or non-path data into PATH.","Wrap runtime spawning with a preflight that joins the intended PATH once and reports failures early."],"tags":["path","env-var","process-spawn","rust"],"backgroundTag":"invalid-env-var-value","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}