You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
Activity
github-actions commentedon Sep 26, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
fix: resolve Windows spawn ENOENT error in SDK
rekram1-node commentedon Sep 26, 2025
@itsrainingmani
cspotcode commentedon Nov 21, 2025
Beware the caveats of
shell: true: https://nodejs.org/api/child_process.html#child_processspawncommand-args-optionsShell is only necessary if we need to execute a
.cmdor.batscript, ifwhere.exe opencodepoints to a text script instead of an executable.You might consider using
execato handle this complexity for you, rather than risking it withshell: true?https://github.com/sindresorhus/execa
More on Windows' spawn complexity: https://github.com/moxystudio/node-cross-spawn?tab=readme-ov-file#why
rekram1-node commentedon Nov 21, 2025
good callout