[PR #8162] fix(sdk): add shell option for Windows spawn compatibility #12646

Open
opened 2026-02-16 18:17:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8162

State: open
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8162 **State:** open **Merged:** No --- ## 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: ```typescript 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
yindo added the pull-request label 2026-02-16 18:17:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12646