Skip to content

Conversation

@jc01rho
Copy link

@jc01rho jc01rho commented Jan 13, 2026

Summary

  • Adds shell: process.platform === 'win32' to both spawn() calls in SDK server module
  • Fixes Windows compatibility issue where npm-installed .cmd wrappers aren't found

Fixes #8160

Problem

On Windows, npm-installed packages create .cmd wrapper scripts (e.g., opencode.cmd). Node.js spawn() without shell: true cannot find these in PATH, causing:

ENOENT: no such file or directory, uv_spawn 'opencode'

Solution

Add conditional shell: true on Windows:

const proc = spawn(\, args, {
  signal: options.signal,
  shell: process.platform === 'win32',  // NEW
  env: { ... },
})

Testing

Verified manually on Windows 11:

  1. Before fix: ENOENT error when calling createOpencodeServer()
  2. After fix: Server spawns successfully, returns URL

Files Changed

  • packages/sdk/js/src/server.ts - both spawn calls
  • packages/sdk/js/src/v2/server.ts - both spawn calls

On Windows, npm-installed packages create .cmd wrapper scripts.
Node.js spawn() without shell: true cannot find these in PATH,
causing ENOENT errors when spawning 'opencode'.

This adds shell: true conditionally on Windows while maintaining
Unix compatibility.

Fixes anomalyco#8160
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Reason for related flag: This PR appears to address the same Windows spawn ENOENT error issue that PR #8162 is fixing. Both target SDK compatibility with Windows .cmd wrapper scripts and the spawn() function error. You may want to verify if #2813 is already merged/closed or if it's a different approach to the same problem.

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.

fix(sdk): spawn fails on Windows - ENOENT for opencode command

1 participant