Skip to content

Windows spawn ENOENT error in OpenCode SDK #2812

Closed

Description

@alanjaouen

The OpenCode SDK fails on Windows with 'spawn opencode ENOENT' error. The spawn() calls need { shell: true } option to resolve executables properly on Windows. Affects createOpencodeServer() and createOpencodeTui() functions in packages/sdk/js/src/server.ts

Activity

  1. github-actions commented on Sep 26, 2025

    @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. added a commit that references this issue on Sep 26, 2025
    71a7b73
  3. self-assigned this
    on Sep 26, 2025
  4. rekram1-node commented on Sep 26, 2025

    @rekram1-node
    Collaborator
  5. cspotcode commented on Nov 21, 2025

    @cspotcode

    Beware the caveats of shell: true: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options

    If the shell option is enabled, do not pass unsanitized user input to this function. Any input containing shell metacharacters may be used to trigger arbitrary command execution.

    Shell is only necessary if we need to execute a .cmd or .bat script, if where.exe opencode points to a text script instead of an executable.

    You might consider using execa to handle this complexity for you, rather than risking it with shell: true?
    https://github.com/sindresorhus/execa

    More on Windows' spawn complexity: https://github.com/moxystudio/node-cross-spawn?tab=readme-ov-file#why

  6. rekram1-node commented on Nov 21, 2025

    @rekram1-node
    Collaborator

    good callout

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions