Skip to content

fix: opencode is not on PATH on Windows#2183

Merged
juliusmarminge merged 6 commits into
pingdotgg:mainfrom
adammansfield:fix/opencode-path-windows
May 1, 2026
Merged

fix: opencode is not on PATH on Windows#2183
juliusmarminge merged 6 commits into
pingdotgg:mainfrom
adammansfield:fix/opencode-path-windows

Conversation

@adammansfield
Copy link
Copy Markdown
Contributor

@adammansfield adammansfield commented Apr 18, 2026

Edit(2026-04-24T15:57Z):
The bug #2163 has been partially fixed in v0.0.21, but the bug still occurs if opencode is a .cmd.
I have updated the pull request and commented below for the latest change at: #2183 (comment)

Edit(2026-04-28T14:07Z):
ssswagatss commented that they were affected by #2163.

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

Thanks

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


Note

Low Risk
Small, platform-gated change to process spawning; risk is limited to Windows runtime behavior when launching the OpenCode server.

Overview
Fixes spawning the local OpenCode serve process on Windows by enabling shell execution in startOpenCodeServerProcess, allowing .cmd/PATH-resolved shims to run correctly.

Non-Windows behavior is unchanged (still detached process groups), but Windows now relies on shell spawning to avoid “command not found” issues.

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

Note

[!NOTE]

Fix opencode not found on PATH when spawning server process on Windows

On Windows, executables resolved via PATH require spawning through a shell. Sets shell: true when calling ChildProcess.make for the serve command on Windows, and explicitly false on other platforms, in opencodeRuntime.ts.

Macroscope summarized d5b5eae.


Open in Devin Review

@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: da8b7faa-cda3-4af3-bc6e-5eb6dbeee391

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[bot]
macroscopeapp Bot previously approved these changes Apr 18, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 18, 2026

Approvability

Verdict: Approved

Single-line Windows-specific bug fix adding shell: true when spawning child processes, a standard pattern for PATH resolution on Windows. No runtime behavior change on other platforms, clear intent, minimal scope.

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
@macroscopeapp macroscopeapp Bot dismissed their stale review April 20, 2026 13:18

Dismissing prior approval to re-evaluate bd398d7

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Apr 20, 2026
@adammansfield
Copy link
Copy Markdown
Contributor Author

adammansfield commented Apr 20, 2026

#2163 is now partially fixed in v0.0.21 for opencode.exe, but it is still broken for opencode.cmd:

npm i -g opencode-ai
where.exe opencode
# C:\Program Files\nodejs\opencode
# C:\Program Files\nodejs\opencode.cmd
image

I have updated this pull request for just the narrow opencode.cmd fix so that shell is used for win32 in startOpenCodeServerProcess:
image

@adammansfield adammansfield changed the title fix: opencode is not on PATH on Windows (#2163) fix: opencode is not on PATH on Windows Apr 28, 2026
@juliusmarminge juliusmarminge merged commit 1eb6fce into pingdotgg:main May 1, 2026
10 checks passed
Morphexe pushed a commit to Morphexe/t3code that referenced this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 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

4 participants