openclaw - ✅(Solved) Fix [Bug]: Windows: spawn claude ENOENT "claude" missing from cmdCommands shim allowlist [3 pull requests, 1 comments, 1 participants]

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…
GitHub stats
openclaw/openclaw#68788Fetched 2026-04-19 15:07:30
View on GitHub
Comments
1
Participants
1
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3labeled ×2referenced ×2commented ×1

On Windows, OpenClaw fails to spawn the Claude CLI with Error: spawn claude ENOENT. Every model in the fallback chain fails. Root cause: "claude" is missing from the cmdCommands allowlist used by resolveWindowsCommandShim, so .cmd is never appended and Node's spawn() can't resolve claude.cmd on Windows.

Error Message

On Windows, OpenClaw fails to spawn the Claude CLI with Error: spawn claude ENOENT. Every model in the fallback chain fails. Root cause: "claude" is missing from the cmdCommands allowlist used by resolveWindowsCommandShim, so .cmd is never appended and Node's spawn() can't resolve claude.cmd on Windows. [process/supervisor] spawn failed: reason=Error: spawn claude ENOENT

Root Cause

On Windows, OpenClaw fails to spawn the Claude CLI with Error: spawn claude ENOENT. Every model in the fallback chain fails. Root cause: "claude" is missing from the cmdCommands allowlist used by resolveWindowsCommandShim, so .cmd is never appended and Node's spawn() can't resolve claude.cmd on Windows.

Fix Action

Fixed

PR fix notes

PR #68817: fix: add claude, codex, hermes to Windows .cmd shim allowlist

Description (problem / solution / changelog)

Fixes #68788

On Windows, spawning claude (and similar CLI tools installed via npm) fails with ENOENT because resolveWindowsCommandShim only appends .cmd for a hardcoded allowlist of commands (npm, pnpm, yarn, npx).

This PR adds claude, codex, and hermes to the cmdCommands array so their .cmd shims are found on Windows.

Also adds a test covering the new entries.

Changed files

  • src/process/supervisor/adapters/child.ts (modified, +1/-1)
  • src/process/windows-command.test.ts (modified, +12/-0)

PR #68819: fix: resolve Windows .cmd shims to underlying .exe before spawn

Description (problem / solution / changelog)

Summary

  • Problem: On Windows, every provider=claude-cli spawn fails at the supervisor with spawn claude ENOENT; the fallback chain cascades and the user sees Embedded agent failed before reply.
  • Why it matters: Claude CLI is unusable on Windows — Discord, webchat, and any other channel routing to claude-cli is broken.
  • What changed: .cmd shims are now resolved to their underlying .exe (or node.exe <cli.js>) and spawned directly, bypassing Node's CVE-2024-27980 restriction on .cmd and cmd.exe's argument-escaping limits. "claude" added to the supervisor's cmdCommands allowlist.
  • What did NOT change (scope boundary): no non-Windows behavior changed, resolveChildProcessInvocation in exec.ts is untouched, and shims with non-npm-bin bodies fall through to the original spawn path.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #68788
  • Related N/A
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: "claude" was missing from the supervisor's cmdCommands allowlist, so resolveWindowsCommandShim returned "claude" unchanged and spawn("claude", …) failed ENOENT. Adding "claude" then surfaces a second bug: Node >=18.20.2 rejects spawn("claude.cmd", …) with EINVAL (CVE-2024-27980), and wrapping via cmd.exe /d /s /c fails because system prompts contain \r \n & | < > ^ % which cmd.exe cannot parse.
  • Missing detection / guardrail: no coverage for spawning non-npm .cmd shims through the supervisor's child adapter on Windows.
  • Contributing context (if known): resolveNpmArgvForWindows in src/process/exec.ts already solves the .cmd-vs-CVE problem for npm/npx, but the supervisor's createChildAdapter does not route through resolveChildProcessInvocation, so it did not inherit that protection.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/process/windows-command.test.ts
  • Scenario the test should lock in: resolveWindowsCmdShimArgv rewrites argv[0] from a .cmd shim to its underlying .exe, prepends process.execPath for .js targets, performs PATH lookup for bare names, and leaves argv unchanged on non-Windows / missing file / non-matching shim body.
  • Why this is the smallest reliable guardrail: the bug lives entirely in how the supervisor resolves the command before spawn, so unit-testing the resolver covers it without a full Windows spawn harness.
  • Existing test that already covers this (if any): none
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • claude-cli-backed providers now spawn successfully on Windows where they previously failed with spawn claude ENOENT.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (Yes but narrowly)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: The helper reads argv[0] as a path and spawns the .exe it names. The path source is unchanged — it comes from OpenClaw's own resolveCommand output and process.env.PATH, same as before. The regex matches only the narrow npm-bin shim pattern ("%dp0%…target.(exe|js)" %*); any non-matching shim falls through and the original argv is spawned as-is. No new untrusted input is introduced.

Repro + Verification

Environment

  • OS: Windows 11 Pro 10.0.26200 (x64)
  • Runtime/container: Node.js v22.22.2
  • Model/provider: claude-cli (Anthropic @anthropic-ai/claude-code, claude.cmd on PATH)
  • Integration/channel (if any): Discord (also reproduces on webchat)
  • Relevant config (redacted): default, Claude CLI authenticated via claude login

Steps

  1. npm i -g openclaw on Windows.
  2. npm i -g @anthropic-ai/claude-code.
  3. openclaw gateway start, send a message via Discord.

Expected

  • Message routes to claude-cli, the CLI spawns, bot replies.

Actual

[process/supervisor] spawn failed: reason=Error: spawn claude ENOENT [model-fallback/decision] decision=candidate_failed ... detail=spawn claude ENOENT (repeats across opus-4-7, sonnet-4-6, opus-4-6, opus-4-5, sonnet-4-5, haiku-4-5) Embedded agent failed before reply: spawn claude ENOENT

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

After pnpm test src/process/windows-command.test.ts: 10 passed. After live Discord run: claude.exe spawns with an absolute path, bot replies normally, no supervisor errors.

Human Verification (required)

  • Verified scenarios: end-to-end Discord message flow on Windows 11 (fails before, succeeds after); pnpm check; pnpm build; bundled dist wires the new helper through correctly.
  • Edge cases checked: bare-name .cmd resolved via PATH; .js target resolved to node.exe <cli.js>; missing shim file and non-matching shim body both fall through unchanged.
  • What I did not verify: .bat shim bodies (only .cmd tested); non-npm shim formats (chocolatey/scoop) — these fall through unchanged but aren't exercised.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)

Risks and Mitigations

  • Risk: a hand-written .cmd whose body coincidentally matches the regex but also does additional batch work (env sets, chained commands) would be bypassed in favor of the detected target.
    • Mitigation: the regex is anchored to the quoted-target + %* shape npm/pnpm/yarn shims use; custom batch scripts with control flow won't match and fall through untouched.

Changed files

  • src/process/supervisor/adapters/child.ts (modified, +10/-3)
  • src/process/windows-command.test.ts (modified, +212/-1)
  • src/process/windows-command.ts (modified, +95/-0)

PR #68849: fix: add "claude" to Windows cmdCommands shim allowlist

Description (problem / solution / changelog)

Fixes #68788

Summary

resolveWindowsCommandShim resolves .cmd shims for Node spawn() on Windows. The allowlist includes npm, pnpm, yarn, npx but is missing claude, causing spawn claude ENOENT when routing to the claude-cli provider.

Changes

Added "claude" to the cmdCommands array in src/process/supervisor/adapters/child.ts.

Test Plan

  • On Windows with claude.cmd on PATH, verify provider=claude-cli model calls succeed
  • On non-Windows, no behavior change (resolveWindowsCommandShim is a no-op)

Changed files

  • src/process/supervisor/adapters/child.ts (modified, +1/-1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

On Windows, OpenClaw fails to spawn the Claude CLI with Error: spawn claude ENOENT. Every model in the fallback chain fails. Root cause: "claude" is missing from the cmdCommands allowlist used by resolveWindowsCommandShim, so .cmd is never appended and Node's spawn() can't resolve claude.cmd on Windows.

Steps to reproduce

  1. Official install script: curl -fsSL https://openclaw.ai/install.sh | bash
  2. Install the Claude CLI (Anthropic's claude.cmd shim on PATH).
  3. Start OpenClaw and send any message that routes to provider=claude-cli.

Expected behavior

OpenClaw resolves claude to claude.cmd on Windows (same way it already does for npm, pnpm, yarn, npx) and the CLI backend process starts successfully. Root cause is in src/process/supervisor/adapters/child.ts: resolveCommand calls resolveWindowsCommandShim({ command, cmdCommands: ["npm","pnpm","yarn","npx"] }) "claude" is not in the list, so the shim returns "claude" unchanged. Node spawn() on Windows can't find .cmd shims without shell: true or an explicit extension → ENOENT.

Fix: add "claude" to that cmdCommands array

Actual behavior

Spawn fails immediately for every model in the fallback chain:

[agent/cli-backend] cli exec: provider=claude-cli model=opus promptChars=984 [process/supervisor] spawn failed: reason=Error: spawn claude ENOENT [model-fallback/decision] decision=candidate_failed requested=claude-cli/claude-opus-4-7 ... detail=spawn claude ENOENT ... (repeats for sonnet-4-6, opus-4-6, opus-4-5, sonnet-4-5, haiku-4-5) ... Embedded agent failed before reply: spawn claude ENOENT

OpenClaw version

2026.4.15

Operating system

Windows 11 Pro (build 10.0.26200)

Install method

curl -fsSL https://openclaw.ai/install.sh | bash

Model

claude-opus-4.7

Provider / routing chain

provider=claude-cli

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

Add "claude" to the cmdCommands array in src/process/supervisor/adapters/child.ts to fix the spawn error on Windows.

Guidance

  • Verify that the claude.cmd shim is installed and on the system's PATH.
  • Check the resolveWindowsCommandShim function to ensure it correctly appends .cmd to the command when "claude" is added to the cmdCommands array.
  • Update the cmdCommands array in child.ts with the suggested fix and test OpenClaw again to confirm the issue is resolved.
  • If issues persist, review the system's PATH and ensure that the claude.cmd shim is correctly installed and accessible.

Example

// In src/process/supervisor/adapters/child.ts
const cmdCommands = ["npm", "pnpm", "yarn", "npx", "claude"]; // Add "claude" to the array

Notes

This fix assumes that the claude.cmd shim is correctly installed and on the system's PATH. If the issue persists after applying the fix, further investigation into the system's configuration and the claude.cmd installation may be necessary.

Recommendation

Apply the workaround by adding "claude" to the cmdCommands array, as this directly addresses the identified root cause of the issue.

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…

FAQ

Expected behavior

OpenClaw resolves claude to claude.cmd on Windows (same way it already does for npm, pnpm, yarn, npx) and the CLI backend process starts successfully. Root cause is in src/process/supervisor/adapters/child.ts: resolveCommand calls resolveWindowsCommandShim({ command, cmdCommands: ["npm","pnpm","yarn","npx"] }) "claude" is not in the list, so the shim returns "claude" unchanged. Node spawn() on Windows can't find .cmd shims without shell: true or an explicit extension → ENOENT.

Fix: add "claude" to that cmdCommands array

Still need to ship something?

×6

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

Back to top recommendations

TRENDING