codex - 💡(How to fix) Fix Windows: `codex doctor` cannot inspect npm global root because it spawns `npm` instead of `npm.cmd`

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

11 ok | 1 idle | 3 notes | 2 warn | 0 fail degraded

Root Cause

The redacted JSON details show the shared root cause:

Fix Action

Fix / Workaround

I validated this as a local patch in codex-rs/cli/src/doctor.rs, with platform regression tests:

The patched local clone passed:

Code Example

[!!] install      npm-managed launch could not inspect npm global root
[!!] updates      npm update target could not be inspected

---

npm root -g failed: program not found

---

> npm.cmd root -g
%APPDATA%\npm\node_modules

---

OS: Windows x86_64
Codex CLI before update: 0.131.0-alpha.9
Codex CLI after update: 0.131.0-alpha.22
Install context: npm
Repo inspected at: openai/codex commit 326e31a

---

11 ok | 1 idle | 3 notes | 2 warn | 0 fail degraded

---

npm install -g @openai/codex@alpha
codex --version
codex doctor --summary --ascii --no-color
codex doctor --json --ascii --no-color
npm.cmd root -g

---

run_command("npm", ["root", "-g"])

---

#[cfg(windows)]
const NPM_COMMAND: &str = "npm.cmd";
#[cfg(not(windows))]
const NPM_COMMAND: &str = "npm";

---

run_command(NPM_COMMAND, ["root", "-g"])

---

#[test]
#[cfg(windows)]
fn npm_command_uses_windows_cmd_shim() {
    assert_eq!(NPM_COMMAND, "npm.cmd");
}

#[test]
#[cfg(not(windows))]
fn npm_command_uses_plain_binary_name() {
    assert_eq!(NPM_COMMAND, "npm");
}

---

cargo test -p codex-cli npm_command -- --nocapture
cargo test -p codex-cli compare_npm_package_roots
cargo test -p codex-cli
cargo clippy --fix --tests --allow-dirty -p codex-cli

---

11 passed
143 passed
all listed integration tests passed
RAW_BUFFERClick to expand / collapse

What happened?

On Windows, codex doctor reports that it cannot inspect the npm global root for an npm-managed Codex install:

[!!] install      npm-managed launch could not inspect npm global root
[!!] updates      npm update target could not be inspected

The redacted JSON details show the shared root cause:

npm root -g failed: program not found

But npm is available through the normal Windows npm shim:

> npm.cmd root -g
%APPDATA%\npm\node_modules

So the warning appears to be a false positive in the doctor/update-target diagnostics rather than a broken npm install.

Environment

OS: Windows x86_64
Codex CLI before update: 0.131.0-alpha.9
Codex CLI after update: 0.131.0-alpha.22
Install context: npm
Repo inspected at: openai/codex commit 326e31a

codex doctor --summary --ascii --no-color after updating to 0.131.0-alpha.22:

11 ok | 1 idle | 3 notes | 2 warn | 0 fail degraded

The warnings are both tied to npm global-root inspection.

Reproduction

On Windows with an npm-managed Codex CLI install:

npm install -g @openai/codex@alpha
codex --version
codex doctor --summary --ascii --no-color
codex doctor --json --ascii --no-color
npm.cmd root -g

Expected:

codex doctor should resolve the npm global root and compare it with CODEX_MANAGED_PACKAGE_ROOT.

Actual:

codex doctor reports npm root -g failed: program not found, while npm.cmd root -g succeeds.

Root-cause hypothesis

codex-rs/cli/src/doctor.rs currently calls:

run_command("npm", ["root", "-g"])

On Windows, npm is commonly resolved as npm.cmd. A direct process spawn can fail to resolve the bare npm command even when npm.cmd is present on PATH.

Proposed fix

Use a platform-specific npm command for the doctor npm-root probe:

#[cfg(windows)]
const NPM_COMMAND: &str = "npm.cmd";
#[cfg(not(windows))]
const NPM_COMMAND: &str = "npm";

Then call:

run_command(NPM_COMMAND, ["root", "-g"])

I validated this as a local patch in codex-rs/cli/src/doctor.rs, with platform regression tests:

#[test]
#[cfg(windows)]
fn npm_command_uses_windows_cmd_shim() {
    assert_eq!(NPM_COMMAND, "npm.cmd");
}

#[test]
#[cfg(not(windows))]
fn npm_command_uses_plain_binary_name() {
    assert_eq!(NPM_COMMAND, "npm");
}

Local verification

The patched local clone passed:

cargo test -p codex-cli npm_command -- --nocapture
cargo test -p codex-cli compare_npm_package_roots
cargo test -p codex-cli
cargo clippy --fix --tests --allow-dirty -p codex-cli

cargo test -p codex-cli result included:

11 passed
143 passed
all listed integration tests passed

I am not opening a PR because docs/contributing.md says unsolicited code contributions are currently closed, but this should be a small targeted fix if the maintainers agree with the diagnosis.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING