{"record":{"id":"c0122eda68c53927","repo":"BigPizzaV3/CodexPlusPlus","slug":"unexpected-native-runtime-layout","errorCode":null,"errorMessage":"Unexpected native runtime layout","messagePattern":"Unexpected native runtime layout","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/native_browser.rs","lineNumber":290,"sourceCode":"    let path = serde_json::to_string(&control.to_str().context(\"Non-Unicode control path\")?)?;\n    let replacement = format!(\n        \"new nf(r,this.clientApi,()=>ze(this.runtime),this.turnEndedTracker,cppNativeIdentificationReader(this.runtime,cD,ze,{path}))\"\n    );\n    Ok(format!(\"{}\\n{HELPER}\", text.replacen(ANCHOR, &replacement, 1)).into_bytes())\n}\n\nfn selected_key(descriptor: &Value, root: &Path) -> Result<String> {\n    let server = &descriptor[\"mcpServers\"][\"cua_repl\"];\n    let node = PathBuf::from(\n        server[\"command\"]\n            .as_str()\n            .context(\"Missing native Node command\")?,\n    );\n    let relative = node\n        .strip_prefix(root)\n        .context(\"Native Node is outside the runtime cache\")?;\n    let parts: Vec<_> = relative.components().collect();\n    ensure!(parts.len() == 3, \"Unexpected native runtime layout\");\n    let key = parts[0]\n        .as_os_str()\n        .to_str()\n        .context(\"Invalid runtime key\")?;\n    ensure!(\n        key_valid(key) && relative == Path::new(key).join(\"bin/node.exe\"),\n        \"Unexpected native runtime layout\"\n    );\n    let env = &server[\"env\"];\n    ensure!(\n        env[\"NODE_REPL_NODE_PATH\"].as_str().map(Path::new) == Some(node.as_path()),\n        \"Conflicting native Node selection\"\n    );\n    let worker = root.join(key).join(\"bin/node_repl.exe\");\n    ensure!(\n        env[\"CUA_REPL_NODE_REPL_PATH\"].as_str().map(Path::new) == Some(worker.as_path()),\n        \"Conflicting native worker selection\"\n    );","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/native_browser.rs#L272-L308","documentation":"selected_key validates a discovered native CUA runtime descriptor by checking that the configured node command sits at a fixed layout relative to the runtime cache root: exactly 3 path components (<runtime-key>/bin/node.exe). This error is thrown when the node command, relative to the runtime cache root, does not decompose into exactly 3 components — i.e. the executable lives in a nested or flat directory this library does not recognize.","triggerScenarios":"discover() -> selected_key() on an MCP descriptor whose mcpServers.cua_repl.command points at a node binary not matching <root>/<key>/bin/node.exe: an unusual install layout, a custom node path in the descriptor, a moved or renamed runtime cache directory.","commonSituations":"User reinstalled Node/ Codex runtime into a custom location and hand-edited the descriptor; cache root passed to discover differs from the one used to write the descriptor (LOCALAPPDATA redirection, portable install); a runtime-cache migration changed the directory depth.","solutions":["Point mcpServers.cua_repl.command back at <runtime-root>/<key>/bin/node.exe for a runtime inside the cache root.","Verify the runtime cache root is correct (LOCALAPPDATA/OpenAI/Codex/runtimes/cua_node) and that discover is called with the same root that produced the descriptor.","Reinstall/repair the native CUA runtime so it regenerates the expected <key>/bin/node.exe layout.","If a newer runtime intentionally changes layout, update the layout check (parts.len() == 3 and the bin/node.exe path) in native_browser.rs."],"exampleFix":"// before: descriptor command points outside the expected layout\n\"command\": \"D:/tools/node/node.exe\"\n// after: command inside the runtime cache with key/bin/node.exe layout\n\"command\": \"C:/Users/me/AppData/Local/OpenAI/Codex/runtimes/cua_node/rt-1/bin/node.exe\"","handlingStrategy":"validation","validationCode":"let node = PathBuf::from(descriptor[\"mcpServers\"][\"cua_repl\"][\"command\"].as_str()?);\nlet rel = node.strip_prefix(&runtime_root)?;\nif rel.components().count() != 3 {\n    eprintln!(\"runtime layout unexpected: {}\", rel.display());\n    reinstall_runtime()?;\n}","typeGuard":"fn has_canonical_layout(node: &Path, root: &Path) -> bool {\n    node.strip_prefix(root)\n        .map(|rel| {\n            rel.components().count() == 3\n                && rel.starts_with(\"bin\")\n                && rel.ends_with(\"node.exe\")\n        })\n        .unwrap_or(false)\n}","tryCatchPattern":"match selected_key(&descriptor, &root) {\n    Ok(key) => use_runtime(key),\n    Err(e) if e.to_string().contains(\"Unexpected native runtime layout\") => {\n        repair_or_reinstall_runtime()?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the runtime cache under the default LOCALAPPDATA path","Never hand-edit the mcpServers.cua_repl command path","Reinstall the runtime rather than moving/renaming its directories","After moving caches, regenerate the descriptor instead of updating paths manually"],"tags":["rust","path-layout","runtime-discovery","validation"],"backgroundTag":"unexpected-file-layout","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}