Skip to content

fix: opencode is not on PATH on Windows (#2163)#2183

Open
adammansfield wants to merge 1 commit intopingdotgg:mainfrom
adammansfield:fix/opencode-path-windows
Open

fix: opencode is not on PATH on Windows (#2163)#2183
adammansfield wants to merge 1 commit intopingdotgg:mainfrom
adammansfield:fix/opencode-path-windows

Conversation

@adammansfield
Copy link
Copy Markdown
Contributor

@adammansfield adammansfield commented Apr 18, 2026

What Changed

This fixes #2163.

  1. Fix resolving opencode path on Windows by using where.exe (similar as which on macOS and Linux).
  2. Spawn opencode with shell on Windows.

Why

  1. Fix resolving opencode as it could not be found on Windows.
  2. Spawn opencode with shell on Windows because opencode may be a .cmd shim (e.g. with npm i -g opencode-ai)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes -- no UI changes
  • I included a video for animation/interaction changes -- no animation/interaction changes

Manual Testing

Tested the two opencode installations from https://opencode.ai/download that are possible for Windows.

npm i -g opencode-ai
where.exe opencode
# C:\Program Files\nodejs\opencode
# C:\Program Files\nodejs\opencode.cmd
bun add -g opencode-ai
where.exe opencode
# C:\Users\adam\.bun\bin\opencode.exe

Before:
image

After:
image

Tests

Extended "resolves command names through PATH" to handle resolving the opencode on Windows using where.exe.

Validation

  • bun fmt
  • bun lint
  • bun typecheck
  • cd apps/server && bun run test -- src/provider/opencodeRuntime.test.ts -t "resolves command names through PATH"

Thanks

Thanks to @timm-u for his suggested fixes and to @IuriGuerreiro for filing the bug.


Note

Medium Risk
Touches process execution and binary resolution logic; mistakes could prevent the OpenCode server from starting on Windows or change which executable is invoked.

Overview
Fixes Windows support for launching opencode.

resolveOpenCodeBinaryPath now uses where.exe on win32 (parsing CRLF/LF output and returning the first non-empty hit) instead of relying on which. startOpenCodeServerProcess enables spawn(..., { shell: true }) on Windows so .cmd shims can be executed.

Updates opencodeRuntime.test.ts to cover the Windows-specific where.exe resolution path.

Reviewed by Cursor Bugbot for commit fc012cd. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix opencode binary not found on PATH on Windows

  • In opencodeRuntime.ts, resolveOpenCodeBinaryPath now uses where.exe on Windows instead of which, splitting output on CRLF/LF and returning the first non-empty path.
  • The server process spawned by startOpenCodeServerProcess now sets shell: true on Windows to correctly resolve the opencode.cmd shim.
  • Tests in opencodeRuntime.test.ts are extended to cover Windows-specific where.exe behavior.

Macroscope summarized fc012cd.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 18, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: adb14a41-ba77-426a-8f8d-f57e8fb682c6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 18, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 18, 2026

Approvability

Verdict: Approved

This is a straightforward Windows platform bug fix that adds proper PATH resolution using where.exe instead of Unix-only which, and enables shell mode for resolving .cmd shims. The changes are isolated to Windows, don't affect existing behavior on other platforms, and include corresponding tests.

You can customize Macroscope's approvability policy. Learn more.

@adammansfield adammansfield force-pushed the fix/opencode-path-windows branch from e047e97 to fc012cd Compare April 18, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Nightly - OpenCode provider false "not installed / not on PATH" on Windows

1 participant