Skip to content

spawn codex ENOENT on Windows: companion script fails to find codex CLI #50

Closed

Description

@0xZOne

Description

The Codex review plugin fails on Windows with spawn codex ENOENT when the companion script attempts to spawn the codex CLI via child_process.spawn.

Environment

  • OS: Windows 11 Pro 10.0.22631
  • Shell: Git Bash (MINGW64)
  • Node: v22.17.0
  • npm: 10.9.2
  • codex-cli: 0.117.0
  • Claude Code plugin: codex 1.0.1

Steps to Reproduce

  1. Install codex globally: npm install -g @openai/codex
  2. Verify codex is available: codex --version → codex-cli 0.117.0
  3. Install the plugin in Claude Code: /plugin install codex@openai-codex
  4. Run /codex:review

Expected Behavior

The companion script spawns codex and runs the review.

Actual Behavior

spawn codex ENOENT

The script exits with code 1.

Root Cause

The companion script (scripts/codex-companion.mjs) uses child_process.spawn('codex', ...) without { shell: true }. On Windows, npm global installs create .cmd wrapper scripts (e.g., codex.cmd), not raw executables. Node.js spawn without shell: true cannot resolve .cmd files, resulting in ENOENT.

This is a well-known Node.js/Windows issue: https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows

Workaround

Running codex review --uncommitted directly in terminal works fine.

Suggested Fix

Add { shell: true } on Windows:

const child = spawn('codex', args, {
  ...options,
  shell: process.platform === 'win32',
});

Or use cross-spawn / execa which handle this automatically.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions