How to install OpenCode easily on Windows #1621

Closed
opened 2026-02-16 17:31:47 -05:00 by yindo · 16 comments
Owner

Originally created by @weroperking on GitHub (Sep 5, 2025).

Originally assigned to: @thdxr on GitHub.

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.ps1 wrapper tries to call /bin/sh.exe, which doesn’t exist on Windows.

In Git Bash

opencode
# => cannot execute binary file
  • bin/opencode is 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

  1. Run the binary directly

    & "C:\Users\<User>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe"
    
  2. 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 .exe instead of /bin/sh.
  • This would allow opencode to 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.

Originally created by @weroperking on GitHub (Sep 5, 2025). Originally assigned to: @thdxr on GitHub. ## Problem After installing **`opencode-ai`** globally on **Windows** via npm, the `opencode` command does not work out of the box. ### In PowerShell ```powershell opencode # => & : The term '/bin/sh.exe' is not recognized ... ``` - The auto-generated `opencode.ps1` wrapper tries to call `/bin/sh.exe`, which doesn’t exist on Windows. ### In Git Bash ```bash opencode # => cannot execute binary file ``` - `bin/opencode` is 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 1. **Run the binary directly** ```powershell & "C:\Users\<User>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe" ``` 2. **Patch the wrapper script (`opencode.ps1`) manually** Replace: ```powershell & "/bin/sh$exe" "$basedir/node_modules/opencode-ai/bin/opencode" $args ``` With: ```powershell & "$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 `.exe` instead of `/bin/sh`. - This would allow `opencode` to 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`.
yindo closed this issue 2026-02-16 17:31:47 -05:00
Author
Owner

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

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

  • #631: General Windows support tracking issue
  • #1945: Similar npm installation failures on Windows with symlink permission errors

The core problem described (PowerShell wrapper calling /bin/sh.exe and Git Bash unable to execute Unix shell scripts) appears to be part of the broader Windows installation issues already being tracked.

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

@github-actions[bot] commented on GitHub (Sep 5, 2025): This issue might be a duplicate of existing issues. Please check: - #631: General Windows support tracking issue - #1945: Similar npm installation failures on Windows with symlink permission errors The core problem described (PowerShell wrapper calling /bin/sh.exe and Git Bash unable to execute Unix shell scripts) appears to be part of the broader Windows installation issues already being tracked. Feel free to ignore if none of these address your specific case.
Author
Owner

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

we should definitely fix that

@rekram1-node commented on GitHub (Sep 5, 2025): we should definitely fix that
Author
Owner

@VictorZakharov commented on GitHub (Sep 6, 2025):

Needs to be easier, or it won't take off.

@VictorZakharov commented on GitHub (Sep 6, 2025): Needs to be easier, or it won't take off.
Author
Owner

@weroperking commented on GitHub (Sep 6, 2025):

Needs to be easier, or it won't take off.

Like how ?

@weroperking commented on GitHub (Sep 6, 2025): > Needs to be easier, or it won't take off. Like how ?
Author
Owner

@weroperking commented on GitHub (Sep 6, 2025):

Needs to be easier, or it won't take off.

Anyway, i got another problem after the setup, I don't know if it happend to someone else

The LLM model wwritesthe code nnormally but no files aappearin the directory, do you have any idea

@weroperking commented on GitHub (Sep 6, 2025): > Needs to be easier, or it won't take off. Anyway, i got another problem after the setup, I don't know if it happend to someone else The LLM model wwritesthe code nnormally but no files aappearin the directory, do you have any idea
Author
Owner

@VictorZakharov commented on GitHub (Sep 6, 2025):

Installation on Windows should be 1 command + register on LLM like Claude. It should not be more complex than Claude Code itself. While it is more complex, Windows users will use other tools. I'm a software architect.

@VictorZakharov commented on GitHub (Sep 6, 2025): Installation on Windows should be 1 command + register on LLM like Claude. It should not be more complex than Claude Code itself. While it is more complex, Windows users will use other tools. I'm a software architect.
Author
Owner

@weroperking commented on GitHub (Sep 6, 2025):

Installation on Windows should be 1 command + register on LLM like Claude. It should not be more complex than Claude Code itself. While it is more complex, Windows users will use other tools. I'm a software architect.

Actually I am installing Crush CLI , cuz I got a problems with Opencode , except the installation the agents don't event work properly.

@weroperking commented on GitHub (Sep 6, 2025): > Installation on Windows should be 1 command + register on LLM like Claude. It should not be more complex than Claude Code itself. While it is more complex, Windows users will use other tools. I'm a software architect. Actually I am installing Crush CLI , cuz I got a problems with Opencode , except the installation the agents don't event work properly.
Author
Owner

@itsrainingmani commented on GitHub (Sep 8, 2025):

we should definitely fix that

I have a PR open to address this issue - https://github.com/sst/opencode/pull/2419

@itsrainingmani commented on GitHub (Sep 8, 2025): > we should definitely fix that I have a PR open to address this issue - https://github.com/sst/opencode/pull/2419
Author
Owner

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

@itsrainingmani I saw that, I sent it to Dax to review

@rekram1-node commented on GitHub (Sep 8, 2025): @itsrainingmani I saw that, I sent it to Dax to review
Author
Owner

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

I just added him as a reviewer too, but I dmed it to him yesterday

@rekram1-node commented on GitHub (Sep 8, 2025): I just added him as a reviewer too, but I dmed it to him yesterday
Author
Owner

@itsrainingmani commented on GitHub (Sep 8, 2025):

Thanks! We could probably also update the installation documentation to include Chocolatey, Scoop and WinGet as alternative installation options for Windows. I can make a PR for that.

@itsrainingmani commented on GitHub (Sep 8, 2025): Thanks! We could probably also update the installation documentation to include Chocolatey, Scoop and WinGet as alternative installation options for Windows. I can make a PR for that.
Author
Owner

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

Closing since npm install was addressed by: https://github.com/sst/opencode/pull/2419

@rekram1-node commented on GitHub (Sep 8, 2025): Closing since npm install was addressed by: https://github.com/sst/opencode/pull/2419
Author
Owner

@vec715 commented on GitHub (Sep 10, 2025):

installation via npm still does not work on windows

@vec715 commented on GitHub (Sep 10, 2025): installation via npm still does not work on windows
Author
Owner

@weroperking commented on GitHub (Sep 10, 2025):

installation via npm still does not work on windows

Try to do the same steps in issues

@weroperking commented on GitHub (Sep 10, 2025): > installation via npm still does not work on windows Try to do the same steps in issues
Author
Owner

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

I think @itsrainingmani said he was working on fixing it again, btw since windows support is lacking we have this big issue to track these things: https://github.com/sst/opencode/issues/631

For now I recommend using:

choco install opencode
@rekram1-node commented on GitHub (Sep 10, 2025): I think @itsrainingmani said he was working on fixing it again, btw since windows support is lacking we have this big issue to track these things: https://github.com/sst/opencode/issues/631 For now I recommend using: ``` choco install opencode ```
Author
Owner

@p-dot-max commented on GitHub (Feb 16, 2026):

If opencode is installed but shows as "unrecognized command" or to use in windows, follow the steps below.


Install Globally

npm i -g opencode-ai

Add npm Global Path to Environment Variables

Add the following path to Path under both:

  • User Variables
  • System Variables
C:\Users\<your-username>\AppData\Roaming\npm

Replace <your-username> with your actual Windows username.


Restart Terminal

Close all terminals and open a new Command Prompt or PowerShell window.


Verify Installation

opencode --version

If a version number is displayed, the installation is working correctly.

@p-dot-max commented on GitHub (Feb 16, 2026): If `opencode` is installed but shows as **"unrecognized command"** or **to use in windows**, follow the steps below. --- ## Install Globally ```bash npm i -g opencode-ai ``` --- ## Add npm Global Path to Environment Variables Add the following path to **Path** under both: * User Variables * System Variables ``` C:\Users\<your-username>\AppData\Roaming\npm ``` > Replace `<your-username>` with your actual Windows username. --- ## Restart Terminal Close all terminals and open a new Command Prompt or PowerShell window. --- ## Verify Installation ```bash opencode --version ``` If a version number is displayed, the installation is working correctly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1621