[Bug] Windows: opening Codex desktop from CCR fails with "spawn EINVAL" (CODEX_CLI_PATH injected as .cmd middleware, refused by modern Node)
TL;DR(中文):Windows 上从 CCR 打开 Codex 桌面版必现弹窗 ChatGPT failed to start. / spawn EINVAL。根因:CCR 把 CODEX_CLI_PATH 注入为 bin\ccr-codex-cli-stdio-<profile>.cmd(stdio 中间件),而 Codex 桌面版用 child_process.spawn(..., {shell:false}) 启动它——Node 自 CVE-2024-27980 修复起拒绝无 shell 启动批处理,同步抛 spawn EINVAL,bootstrap 捕获后弹窗。把 CODEX_CLI_PATH 指回真实 codex.exe 后实例稳定运行数小时。
Environment
- Windows 11
- CCR desktop 3.1.1
- Codex desktop 26.917.9434.0 (portable payload)
- Profile:
scope=ccr,agent=codex,surface=app
Symptom
Clicking launch: the window appears briefly, then a native dialog:
ChatGPT failed to start. spawn EINVAL
Root cause
- CCR generates
bin\ccr-codex-cli-stdio-<profile>.cmdand injects it asCODEX_CLI_PATHin the app launch env (the.cmdeven branches on%~1 == app-server— it is designed to be spawned by the desktop app). - The Codex desktop app spawns
CODEX_CLI_PATHviachild_process.spawn(..., {shell:false})for its AppServerConnection (stdio transport). - Since Node CVE-2024-27980 fix (Node >= 18.20 / 20.12), spawning a
.cmd/.batwithout a shell throwsspawn EINVALsynchronously. - The rejection propagates to the desktop bootstrap catch → startup-failure dialog.
Every Windows user opening the Codex desktop app from CCR with a current Codex build is affected.
Evidence (stderr of the launched app)
[AppServerConnection] app_server_connection.transport_connect_failed errorCode=EINVAL errorMessage="spawn EINVAL"
at ChildProcess.spawn (node:internal/child_process:...)
[AppServerConnection] fatal_error_broadcasted errorMessage="spawn EINVAL" transportKind=stdio
Desktop bootstrap failed to start the main app phase=bootstrap-import-mainRepro matrix (identical env except CODEX_CLI_PATH)
| CODEX_CLI_PATH | Result |
|---|---|
...\bin\ccr-codex-cli-stdio-<profile>.cmd |
100% fail: spawn EINVAL dialog |
<payload>\resources\codex.exe |
Codex CLI initialized; instance stable for hours |
Suggested fix
For surface=app, inject CODEX_CLI_PATH = the real codex.exe. App-surface model routing already comes from the scope=ccr config.toml rewrite (model_provider = "claude-code-router"), so the middleware shim is not on the critical path. Keep the .cmd for the CLI copy-command surface only — it runs inside a terminal (cmd.exe), which is unaffected by the Node restriction.
Workaround (local)
Intercept the spawn env before the desktop app starts and repoint CODEX_CLI_PATH to resources\codex.exe — verified stable. Newly created codex profiles hit the same bug (auto-detected appPath bypasses any local workaround), so an upstream fix is worthwhile.
Source: musistudio/claude-code-router