Skip to content

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

Closed as not planned

Description

@jc01rho

Description

The SDK's createOpencodeServer and createOpencodeTui functions fail on Windows with:

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

Root Cause

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

Affected Files

  • packages/sdk/js/src/server.ts (lines 34 and 109)
  • packages/sdk/js/src/v2/server.ts (same locations)

Proposed Fix

Add shell: process.platform === 'win32' to both spawn() calls:

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

How to Reproduce

  1. Install OpenCode via npm on Windows: npm i -g opencode-ai
  2. Use the SDK to spawn the server:
    import { createOpencodeServer } from '@opencode-ai/sdk/server'
    await createOpencodeServer({ port: 0 })
  3. Observe ENOENT error

Verified Fix

Tested the fix manually - adding shell: true on Windows resolves the issue while maintaining Unix compatibility.

OpenCode Version

1.1.16

Operating System

Windows 11

Activity

  1. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions