Skip to content

How to install OpenCode easily on Windows #2447

@weroperking

Description

@weroperking

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions