Skip to content

fix(cli): run the curl installer with Git Bash on Windows - #53029

Merged
neriousy merged 1 commit into
v2from
windows-installer-bash
Oct 3, 2026
Merged

neriousy merged 1 commit into
v2from
windows-installer-bash

Conversation

@neriousy

@neriousy neriousy commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #52815
Closes #50924
Closes #50950

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode upgrade / /update with the curl method runs the downloaded installer with a bare bash. On Windows that often resolves to the WSL launcher (System32\bash.exe or the WindowsApps alias) because a stock Git for Windows install only puts Git\cmd on PATH. WSL bash can't read the installer at its Windows path, so the upgrade fails with /bin/bash: C:...install: No such file or directory.

On Windows the updater now picks the installer's interpreter explicitly:

  1. OPENCODE_GIT_BASH_PATH, the existing documented override already used by the server.
  2. Git Bash derived from git --exec-path (<Git>/mingw64/libexec/git-core → <Git>/bin/bash.exe), which also handles custom install locations such as D:\Program Files\Git.
  3. Otherwise it fails before downloading anything, with "Git Bash is required to update OpenCode" and a hint to install Git for Windows or set the override.

Non-Windows behavior is unchanged.

Related: #51038 targets the same bug by probing uname -s on every bash candidate. This version is smaller and was exercised end to end on Windows (below). It does not support machines with only MSYS2/Cygwin bash and no Git for Windows; those can use OPENCODE_GIT_BASH_PATH.

How did you verify your code works?

  • bun test test/updater-install.test.ts and bun typecheck in packages/cli; bun run check from the root.
  • End to end on Windows 11 26200 with WSL installed. Each run used a sandboxed home (USERPROFILE/HOME), the real PATH with Git\bin removed so bare bash resolved to the WSL alias, and the real installer and npm package to upgrade 2.0.21 → 2.0.22:
Binary Setup Result
released 2.0.21 (npm) Git\cmd on PATH fails: /bin/bash: ...\install: No such file or directory
this branch, built as 2.0.21 Git\cmd on PATH upgrades to 2.0.22 via C:\Program Files\Git\bin\bash.exe, writes opencode2.cmd
this branch no git on PATH fails before download with the Git Bash message
this branch no git, OPENCODE_GIT_BASH_PATH set upgrades to 2.0.22

Screenshots / recordings

CLI only. Failure output when Git Bash can't be found:

x  Git Bash is required to update OpenCode
|  The OpenCode installer runs with Git Bash on Windows, and it was not found.
|  Retry    Install Git for Windows or set OPENCODE_GIT_BASH_PATH, then run opencode upgrade again.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

A bare `bash` on Windows often resolves to the WSL launcher, which cannot
read the downloaded installer at its Windows path. Locate Git Bash through
`git --exec-path`, honor OPENCODE_GIT_BASH_PATH, and fail with a clear
message before downloading when neither is available.
@neriousy
neriousy force-pushed the windows-installer-bash branch from 42a2364 to 5c56a16 Compare October 3, 2026 22:19
@neriousy
neriousy merged commit e8c75c2 into v2 Oct 3, 2026
11 checks passed
@neriousy
neriousy deleted the windows-installer-bash branch October 3, 2026 22:29
Ichinose-Kazuki pushed a commit to Ichinose-Kazuki/opencode that referenced this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant