Windows spawn ENOENT error in OpenCode SDK #1851

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

Originally created by @alanjaouen on GitHub (Sep 26, 2025).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @alanjaouen on GitHub (Sep 26, 2025). Originally assigned to: @rekram1-node on GitHub. 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
yindo added the windows label 2026-02-16 17:32:56 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 26, 2025):

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

  • #2799: ENOENT error when referencing file paths in OpenCode AI CLI (windows) - similar Windows ENOENT error, though CLI-related rather than SDK-related

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

@github-actions[bot] commented on GitHub (Sep 26, 2025): This issue might be a duplicate of existing issues. Please check: - #2799: ENOENT error when referencing file paths in OpenCode AI CLI (windows) - similar Windows ENOENT error, though CLI-related rather than SDK-related Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 26, 2025):

@itsrainingmani

@rekram1-node commented on GitHub (Sep 26, 2025): @itsrainingmani
Author
Owner

@cspotcode commented on GitHub (Nov 21, 2025):

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

@cspotcode commented on GitHub (Nov 21, 2025): 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
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

good callout

@rekram1-node commented on GitHub (Nov 21, 2025): good callout
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1851