-
Notifications
You must be signed in to change notification settings - Fork 14.9k
How to install OpenCode easily on Windows #2447
Copy link
Copy link
Closed
Description
Problem
After installing opencode-ai globally on Windows via npm, the opencode command does not work out of the box.
In PowerShell
opencode
# => & : The term '/bin/sh.exe' is not recognized ...- The auto-generated
opencode.ps1wrapper tries to call/bin/sh.exe, which doesn’t exist on Windows.
In Git Bash
opencode
# => cannot execute binary filebin/opencodeis a Unix shell script, so Git Bash tries to run it as a Linux binary.- But the package already bundles a valid Windows binary:
node_modules/opencode-ai/node_modules/opencode-windows-x64/bin/opencode.exe
Root Cause
- The npm wrapper (
opencode.ps1) assumes a Unix shell (/bin/sh). - On Windows, this path is invalid, so the wrapper fails.
- Git Bash also fails because it doesn’t know to call the
.exe.
Workarounds
-
Run the binary directly
& "C:\Users\<User>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe"
-
Patch the wrapper script (
opencode.ps1) manually
Replace:& "/bin/sh$exe" "$basedir/node_modules/opencode-ai/bin/opencode" $args
With:
& "$basedir/node_modules/opencode-ai/node_modules/opencode-windows-x64/bin/opencode.exe" $args
Feature Request
Please update the npm installation process so that:
- On Windows, the wrapper calls the bundled
.exeinstead of/bin/sh. - This would allow
opencodeto run out of the box in PowerShell and Git Bash without manual editing.
⚡ This would make installation seamless for Windows developers and avoid the confusion around /bin/sh.exe and cannot execute binary file.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels