openclaw - 💡(How to fix) Fix claude-cli runtime fails on Windows: spawn claude ENOENT (Node spawn doesn't resolve .cmd shims) [1 comments, 2 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#80351Fetched 2026-05-11 03:15:42
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Timeline (top)
labeled ×2closed ×1commented ×1

When agents.defaults.agentRuntime.id is set to "claude-cli" and a request routes through the cli-backend on Windows, the gateway fails with Error: spawn claude ENOENT even though @anthropic-ai/claude-code is correctly installed and claude.cmd is on %PATH%. Root cause: in dist/cli-backend-*.js the Anthropic CLI backend hardcodes command: "claude". On Windows, Node's child_process.spawn (without shell: true) only resolves .exe files via CreateProcess and ignores the .cmd shim that npm installs. The actual claude.exe ships deep inside node_modules/@anthropic-ai/claude-code/bin/, which is not on PATH, so the spawn fails.

Error Message

[agent/cli-backend] cli exec: provider=claude-cli model=sonnet promptChars=188 trigger=user useResume=false session=none resumeSession=none reuse=none historyPrompt=none [process/supervisor] spawn failed: runId=9f0408f7-... reason=Error: spawn claude ENOENT Embedded agent failed before reply: spawn claude ENOENT

Root Cause

When agents.defaults.agentRuntime.id is set to "claude-cli" and a request routes through the cli-backend on Windows, the gateway fails with Error: spawn claude ENOENT even though @anthropic-ai/claude-code is correctly installed and claude.cmd is on %PATH%. Root cause: in dist/cli-backend-*.js the Anthropic CLI backend hardcodes command: "claude". On Windows, Node's child_process.spawn (without shell: true) only resolves .exe files via CreateProcess and ignores the .cmd shim that npm installs. The actual claude.exe ships deep inside node_modules/@anthropic-ai/claude-code/bin/, which is not on PATH, so the spawn fails.

Fix Action

Fix / Workaround

function buildAnthropicCliBackend() { return { id: CLAUDE_CLI_BACKEND_ID, // ... config: { command: "claude", // <-- bare string; resolved by Node spawn on Windows without shell:true args: ["-p", "--output-format", "stream-json", /* ... */] } }; }

Workaround for users hitting this today

No gateway restart needed; PATH lookup happens at spawn time. Verified end-to-end: Sonnet, Haiku, and Opus all reply correctly through the cli-backend after this workaround.

Code Example

[agent/cli-backend] cli exec: provider=claude-cli model=sonnet promptChars=188 trigger=user useResume=false session=none resumeSession=none reuse=none historyPrompt=none
[process/supervisor] spawn failed: runId=9f0408f7-... reason=Error: spawn claude ENOENT
Embedded agent failed before reply: spawn claude ENOENT

---

Reproduces deterministically. Source-level evidence in the installed copy of `dist/cli-backend-BlVdMXrZ.js`:


function buildAnthropicCliBackend() {
  return {
    id: CLAUDE_CLI_BACKEND_ID,
    // ...
    config: {
      command: "claude",   // <-- bare string; resolved by Node spawn on Windows without shell:true
      args: ["-p", "--output-format", "stream-json", /* ... */]
    }
  };
}


Node's `child_process.spawn("claude", args)` on Windows uses `CreateProcess`, which does not honor PATHEXT and only directly executes `.exe` files. npm's global install of `@anthropic-ai/claude-code` places these in `%APPDATA%\npm`:


claude        # POSIX shell script (#!/bin/sh) - Windows can't run
claude.cmd    # cmd shim that calls the .exe - Node spawn won't find
claude.ps1    # PowerShell shim - Node spawn won't find


The real `claude.exe` (PE32+, 253 MB) sits inside `%APPDATA%\npm\node_modules\@anthropic-ai\claude-code\bin\`, which is not on PATH.

## Suggested fix

Any of:
1. Replace `child_process.spawn` with [`cross-spawn`](https://www.npmjs.com/package/cross-spawn) or `execa` — one-import change, fixes the same class of bug for any other `.cmd`-shimmed CLI you ship.
2. Pass `shell: true` to spawn when `process.platform === "win32"`.
3. On Windows, resolve `command` to the absolute path of `claude.exe` inside the `@anthropic-ai/claude-code` package (or to `claude.cmd`) before spawn.

Option 1 is the cleanest and is what `npm`, `npx`, `pnpm`, `yarn`, and most build tools already use.

## Workaround for users hitting this today

Drop a real `claude.exe` into a directory already on the gateway's PATH:


Copy-Item "$env:APPDATA\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe" "$env:APPDATA\npm\claude.exe"


No gateway restart needed; PATH lookup happens at spawn time. Verified end-to-end: Sonnet, Haiku, and Opus all reply correctly through the cli-backend after this workaround.
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

When agents.defaults.agentRuntime.id is set to "claude-cli" and a request routes through the cli-backend on Windows, the gateway fails with Error: spawn claude ENOENT even though @anthropic-ai/claude-code is correctly installed and claude.cmd is on %PATH%. Root cause: in dist/cli-backend-*.js the Anthropic CLI backend hardcodes command: "claude". On Windows, Node's child_process.spawn (without shell: true) only resolves .exe files via CreateProcess and ignores the .cmd shim that npm installs. The actual claude.exe ships deep inside node_modules/@anthropic-ai/claude-code/bin/, which is not on PATH, so the spawn fails.

Steps to reproduce

  1. Install Claude Code globally: npm i -g @anthropic-ai/claude-code on Windows.
  2. In ~/.openclaw/openclaw.json set agents.defaults.agentRuntime.id to "claude-cli" and add a claude-cli auth profile.
  3. Send any prompt routed to an anthropic/* model through the OpenClaw control UI.
  4. Observe the gateway terminal output.

Expected behavior

The cli-backend successfully spawns the locally installed claude.exe, which proxies the prompt to Anthropic and streams the response back to the OpenClaw chat UI.

Actual behavior

Spawn fails with ENOENT. Gateway terminal output:

[agent/cli-backend] cli exec: provider=claude-cli model=sonnet promptChars=188 trigger=user useResume=false session=none resumeSession=none reuse=none historyPrompt=none
[process/supervisor] spawn failed: runId=9f0408f7-... reason=Error: spawn claude ENOENT
Embedded agent failed before reply: spawn claude ENOENT

The end user sees no assistant reply and no error surfaced in the chat UI.

OpenClaw version

2026.5.4

Operating system

Windows 11 (Node 22.22.2)

Install method

npm global

Model

anthropic/claude-sonnet-4-6, anthropic/claude-haiku-4-5, anthropic/claude-opus-4-7 (any anthropic/* model when agentRuntime.id = claude-cli)

Provider / routing chain

openclaw -> cli-backend (claude-cli) -> spawn("claude") -> claude.exe -> api.anthropic.com

Additional provider/model setup details

agents.defaults.agentRuntime.id = "claude-cli" auth.profiles["anthropic:claude-cli"] = { provider: "claude-cli", mode: "oauth" } auth.order.anthropic = ["anthropic:claude-cli", "anthropic:default"] Claude Code CLI is @anthropic-ai/claude-code 2.1.123 (npm-installed; shims live at %APPDATA%\npm\claude.cmd etc.).

Logs, screenshots, and evidence

Reproduces deterministically. Source-level evidence in the installed copy of `dist/cli-backend-BlVdMXrZ.js`:


function buildAnthropicCliBackend() {
  return {
    id: CLAUDE_CLI_BACKEND_ID,
    // ...
    config: {
      command: "claude",   // <-- bare string; resolved by Node spawn on Windows without shell:true
      args: ["-p", "--output-format", "stream-json", /* ... */]
    }
  };
}


Node's `child_process.spawn("claude", args)` on Windows uses `CreateProcess`, which does not honor PATHEXT and only directly executes `.exe` files. npm's global install of `@anthropic-ai/claude-code` places these in `%APPDATA%\npm`:


claude        # POSIX shell script (#!/bin/sh) - Windows can't run
claude.cmd    # cmd shim that calls the .exe - Node spawn won't find
claude.ps1    # PowerShell shim - Node spawn won't find


The real `claude.exe` (PE32+, 253 MB) sits inside `%APPDATA%\npm\node_modules\@anthropic-ai\claude-code\bin\`, which is not on PATH.

## Suggested fix

Any of:
1. Replace `child_process.spawn` with [`cross-spawn`](https://www.npmjs.com/package/cross-spawn) or `execa` — one-import change, fixes the same class of bug for any other `.cmd`-shimmed CLI you ship.
2. Pass `shell: true` to spawn when `process.platform === "win32"`.
3. On Windows, resolve `command` to the absolute path of `claude.exe` inside the `@anthropic-ai/claude-code` package (or to `claude.cmd`) before spawn.

Option 1 is the cleanest and is what `npm`, `npx`, `pnpm`, `yarn`, and most build tools already use.

## Workaround for users hitting this today

Drop a real `claude.exe` into a directory already on the gateway's PATH:


Copy-Item "$env:APPDATA\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe" "$env:APPDATA\npm\claude.exe"


No gateway restart needed; PATH lookup happens at spawn time. Verified end-to-end: Sonnet, Haiku, and Opus all reply correctly through the cli-backend after this workaround.

Impact and severity

Affected: any Windows user with agentRuntime.id = "claude-cli". Severity: High — completely blocks the Claude CLI runtime on Windows. Frequency: 100% reproducible. Consequence: prompts routed to anthropic/* models silently fail; the chat UI shows no assistant response.

Additional information

Workaround above (copy claude.exe into %APPDATA%\npm\) restores function. No gateway restart required.

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

The cli-backend successfully spawns the locally installed claude.exe, which proxies the prompt to Anthropic and streams the response back to the OpenClaw chat UI.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix claude-cli runtime fails on Windows: spawn claude ENOENT (Node spawn doesn't resolve .cmd shims) [1 comments, 2 participants]