Skip to content

Windows: codex-companion.mjs fails with ENOENT because spawnSync can't resolve 'codex' in PATH #161

@Thepushpendra68

Description

@Thepushpendra68

Describe the bug
On Windows, running /codex:review via Claude Code fails immediately with:

Codex CLI is not installed or is missing required runtime support. Install it with \`npm install -g @openai/codex\`, then rerun \`/codex:setup\`.

The Codex CLI IS installed and codex --version works in a terminal, but the companion script's runCommand() uses spawnSync without shell: true, which cannot resolve codex on Windows because Node's spawnSync without shell does not expand PATH on Windows.

To Reproduce

  1. Have Codex CLI installed (npm install -g @openai/codex)
  2. Run codex --version in PowerShell — confirms it works
  3. Run /codex:review in Claude Code on Windows
  4. Observe the "not installed" error

Root Cause
In scripts/lib/process.mjs, the runCommand function uses spawnSync without shell: true:

export function runCommand(command, args = [], options = {}) {
  const result = spawnSync(command, args, {
    cwd: options.cwd,
    env: options.env,
    encoding: "utf8",
    input: options.input,
    stdio: options.stdio ?? "pipe"
  });

On Windows, spawnSync without shell: true cannot resolve commands in the user PATH (like codex installed via npm global). The shell is required to expand PATH.

Evidence

// Without shell — ENOENT on Windows
spawnSync('codex', ['--version'], { stdio: 'pipe' })
// { error: { code: 'ENOENT', syscall: 'spawnSync codex', path: 'codex' } }

// With shell — works fine
spawnSync('codex', ['--version'], { shell: true, stdio: 'pipe' })
// { status: 0, stdout: 'codex-cli 0.118.0' }

Suggested Fix
In scripts/lib/process.mjs, add shell: true for Windows:

export function runCommand(command, args = [], options = {}) {
  const result = spawnSync(command, args, {
    cwd: options.cwd,
    env: options.env,
    encoding: "utf8",
    input: options.input,
    stdio: options.stdio ?? "pipe",
    shell: process.platform === 'win32'  // <-- fix
  });

Environment

  • OS: Windows 11
  • Node.js: v24.12.0
  • Codex CLI: 0.118.0
  • Plugin: openai-codex via Claude Code plugin

Reported by: Thepushpendra68

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions