Repository navigation
fix(cli): pick a Windows bash for the curl installer - #51038
Tsuki-hash wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Correcting what I wrote earlier, because I had the cause wrong twice and the accurate version is more useful to whoever triages this: |
Issue for this PR
Fixes #50924 (#50924)
Relates #50886
Type of change
What does this PR do?
The curl upgrade downloads
https://opencode.ai/v2/installand runs it with a barebash, which is adifferent program on different Windows machines. Git Bash runs the downloaded script fine. The WSL entry
point at
C:\Windows\System32\bash.exeeats the backslashes in the path and exits 127, which is thefailure in #50924:
Handing that same bash a converted
/mnt/c/...path is worse, not better: the script then runs, andbecause
installinstalls whateveruname -sreports, it pulls a Linux binary into the Windows installdirectory. So the thing to choose is the shell, not the path spelling.
curlShellasks each candidate which system it runs on and takes the first that reportsMINGW/MSYS/CYGWIN, the same classification
installuses:OPENCODE_GIT_BASH_PATH(already documentedin
packages/web/src/content/docs/cli.mdx, previously unused here), every hit fromwhere.exe bash,%ProgramFiles%\Git\bin\bash.exe, thenbash. If none of them is a Windows bash the upgrade stops witha message naming what to install instead of an exit-127 path. Non-Windows behavior is unchanged, still
bashwith no extra spawns.Correction (2026-09-25): I previously hedged that #50950 might have a second cause because its error keeps the backslashes, which is how Git Bash words a missing file. @jpgomezv disproved that with the script verified present: under a WSL bash,
bash "C:\Users\<name>\.cache\opencode\update-XXXX\install" --versionstill fails with the backslashes intact. So both wordings come from a WSL entry point, and which one you see depends on which stub answers -System32\bash.exeon some machines, theWindowsAppsalias on others. No deleted file is needed to explain #50950, and this PR is meant to cover both reports.How did you verify your code works?
Not with the repo's checks: there is no Bun on this machine, so
bun typecheckandbun run checkdidnot run and the module itself was never executed. What I did verify, on Windows 11 26200 with Git for
Windows and WSL both installed:
C:\Users\<name>\.cache\opencode\update-nikDwW\install: exit 0,uname -s=MINGW64_NT-10.0-26200. So the path spelling is not the problem.C:\Windows\System32\bash.exewith that same argument: exit 127 with the stripped-path message quoted above. With a/mnt/c/...argument: exit 0 anduname -s=Linux, the wrong-platform outcome described above.uname -sfilter, ported to plain Node (same argv spawn semantics, no shell), in four setups: Git on PATH picks Git Bash; Git installed but absent from PATH recovers it from Program Files, which is the case that fails today; WSL-only reaches the new error;OPENCODE_GIT_BASH_PATHis honored.What would close the remaining gap:
bun typecheckinpackages/cli, and one realopencode upgrade --method curlfrom a shell whose PATH has no Git entry.Screenshots / recordings
CLI rather than UI. Before, on a machine where
bashis the WSL entry point (from #50924):After, where no Windows bash is reachable - this is the text the new branch emits, not a captured run:
Checklist
"Tested locally" above means what the section says it means: the shell choice and the candidate order were exercised on this machine against real Git Bash and real WSL bash, but the module itself was not run and the repo checks did not run.