Skip to content

fix: use cross-spawn for Windows compatibility#57

Merged
vincentkoc merged 2 commits intoopenclaw:mainfrom
sawyer0x110:fix/windows-spawn-cross-spawn
Mar 9, 2026
Merged

fix: use cross-spawn for Windows compatibility#57
vincentkoc merged 2 commits intoopenclaw:mainfrom
sawyer0x110:fix/windows-spawn-cross-spawn

Conversation

@sawyer0x110
Copy link
Contributor

@sawyer0x110 sawyer0x110 commented Mar 5, 2026

Summary

  • rebase the branch onto current main after test: harden adapter coverage across CLI and platform edge cases #69 so it only changes the agent spawn path
  • switch ACP agent startup in src/client.ts from node:child_process.spawn() to cross-spawn while preserving the current buildAgentSpawnOptions() path and windowsHide behavior
  • regenerate pnpm-lock.yaml and drop the stale npm lockfile from the old diff

Why this is still needed

Windows CreateProcess does not resolve .cmd/.bat launchers like npx.cmd through PATHEXT, so agent startup can still fail with spawn EINVAL even after the windowsHide work in #69. This PR keeps the Windows compatibility fix without reintroducing stale branch state.

Testing

  • pnpm run typecheck:tsc
  • pnpm run lint
  • pnpm run build
  • pnpm run test

Notes

  • pnpm run format:check currently reports an existing formatting issue in CONTRIBUTING.md on current main; this branch does not modify that file.

Fixes #48

Replace node:child_process spawn with cross-spawn to fix agent spawning
on Windows. Node.js spawn() uses CreateProcess directly which cannot
resolve .cmd/.bat scripts (e.g. npx.cmd) or PATHEXT, causing all agents
to fail with 'Failed to spawn agent command' on Windows.

cross-spawn is a drop-in replacement that handles PATHEXT resolution,
.cmd script execution, and argument escaping on Windows.
@vincentkoc vincentkoc self-assigned this Mar 9, 2026
@vincentkoc
Copy link
Member

Rebased onto current main and reduced the diff to the merge-relevant Windows fix only.

What changed:

  • preserved the current buildAgentSpawnOptions() + windowsHide path from main
  • switched only the agent spawn call in src/client.ts to cross-spawn
  • regenerated pnpm-lock.yaml
  • removed the stale package-lock.json that came from the original branch

Validation on the rebased branch:

  • pnpm run typecheck:tsc
  • pnpm run lint
  • pnpm run build
  • pnpm run test

pnpm run format:check still flags the existing CONTRIBUTING.md formatting issue from current main, which is outside this branch.

@vincentkoc vincentkoc merged commit d885469 into openclaw:main Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spawn EINVAL in Windows

2 participants