Windows: spawn("codex") in app-server.mjs throws ENOENT (Node does not try PATHEXT for .cmd shims)
Environment
- OS: Windows 11
- Node: v22.x
- codex: 0.128.0 (npm global install)
- Plugin: openai-codex 1.0.1
Symptom
On Windows, invoking codex:rescue (or any path that triggers CodexAppServerClient.connect) fails with:
Error: spawn codex ENOENT
/codex:setup reports ready: true because detection takes a different code path that already uses shell: true, masking the issue.
Root cause
scripts/lib/app-server.mjs:188 calls:
this.proc = spawn("codex", ["app-server"], {
cwd: this.cwd,
env: this.options.env,
stdio: ["pipe", "pipe", "pipe"]
});
On Windows, child_process.spawn does not consult PATHEXT, so it cannot resolve a .cmd shim. The npm global install of @openai/codex only ships:
codex (sh shim, no extension)
codex.cmd
codex.ps1
There is no codex.exe, so spawn falls through with ENOENT.
By contrast, scripts/lib/process.mjs:5 already uses shell: process.platform === "win32" for the same reason — that is why binaryAvailable("codex", ...) works during /codex:setup.
Reproduction
On Windows with codex installed via npm i -g @openai/codex:
// fails with ENOENT
require('child_process').spawn('codex', ['--version']).on('error', console.error);
// works
require('child_process').spawn('codex', ['--version'], { shell: true }).on('error', console.error);
Diagnostic note
Stderr from a failed task-worker often shows a DEP0190 deprecation warning and the ENOENT side by side. They come from different spawn points:
DEP0190originates fromprocess.mjs(usesshell: true+ args array — Node 22+ warns on this combination, but the spawn itself succeeds).ENOENToriginates fromapp-server.mjs:188(noshell: true, fails to resolve the.cmdshim).
Easy to misread as "shell:true is already set but spawn still fails."
Suggested fix
Two options:
-
Match the existing pattern in
process.mjs— addshell: process.platform === "win32"to the spawn options atapp-server.mjs:188. One-line change. Caveat: on Windows this wraps the child incmd.exe, sothis.proc.kill()may leave the actual codex process as an orphan. -
Resolve the executable's full path before spawning — try
codex,codex.cmd,codex.exeagainstPATHEXT(or use a small helper /cross-spawn) and spawn the resolved path directly. No shell wrapper, kill targets the codex process directly. Cleaner long-term fix.
Option 2 is preferable; option 1 is a one-line patch that unblocks Windows users immediately.
Fixed in CBEPX/codex-plugin-cc v1.4.0 (https://github.com/CBEPX/codex-plugin-cc/releases/tag/v1.4.0): on Windows, a bare command name such as codex is now resolved with where.exe against PATHEXT, and a resolved .cmd/.bat shim (including a global npm install -g @openai/codex) is launched through cmd.exe /d /s /v:off /c with cross-spawn-style double caret escaping, instead of relying on Node's own spawn to try PATHEXT and throwing ENOENT; fixed by the same change as #525, upstream PR #669 used as reference, thanks @mittalpk.
claude plugin marketplace add CBEPX/codex-plugin-cc && claude plugin install codex@cbepx
This is a fork release, not an upstream fix, so I'm leaving this issue open for the maintainers here.