You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: upgrade --method bun reports success on Windows but leaves the old binary in place #51386
On Windows, opencode update --method bun prints Upgrade complete but opencode --version still reports the old version (2.0.6). bun does install 2.0.16 into the global package dir and even creates an opencode2 shim, but the opencode.exe on PATH is never replaced because Windows holds a write lock on a running executable. The failure is swallowed and success is reported.
Not a duplicate of #37055: that one is the curl/bash installer path, this is the bun method.
Plugins
None
OpenCode version
2.0.6 (upgrade attempted to 2.0.16); bun global install, bun 1.4.3
Steps to reproduce
bun install -g @opencode/cli (2.0.6), so opencode resolves to %USERPROFILE%\.bun\bin\opencode.exe
With opencode running, run opencode update --method bun
It prints From 2.0.6 → 2.0.16, Upgrade complete, Done resolve
opencode --version still prints opencode v2.0.6
Expected: the new version is in place after a reported success, or the command exits with a clear error if it cannot replace the binary.
The update is only partially applied: bun pm ls -g reports @opencode/[email protected] and %USERPROFILE%\node_modules\@opencode\cli\bin\opencode.exe is v2.0.16, but %USERPROFILE%\.bun\bin\opencode.exe is still v2.0.6. Writing to that file fails with "being used by another process". @opencode/cli's package.json maps both the opencode and opencode2 bin names to the same exe, so bun creates opencode2 and the failure goes unnoticed.
Screenshot and/or share link
┌ Upgrade
● Using method: bun
● From 2.0.6 → 2.0.16
◇ Upgrade complete
└ Done resolve
Adding a real-world occurrence on Windows (x64) with 2.0.19, in case it helps pin the fix.
After updating to 2.0.19, opencode failed to start at all:
无法启动 'D:\Data\npm\global\node_modules\@opencode\cli\bin\opencode.exe'
The specified executable is not a valid application for this OS platform.
What was on disk:
bin/opencode.exe was a 229-byte shell stub, not a PE image:
echo"Error: @opencode/cli's postinstall script was not run.">&2echo"">&2echo"This occurs when installation scripts are disabled.">&2echo"Run the package postinstall script or reinstall with scripts enabled.">&2exit 1
node_modules/@opencode/cli-windows-x64 was not installed (only node_modules/@opencode/cli was present), so postinstall.mjs had nothing to link.
npm config get ignore-scripts returned false, so this was not npm's global config disabling scripts.
The global prefix D:\Data\npm\global contains bun/bunx shims, so bun may have been involved in the install path; bun does not run dependency lifecycle scripts by default.
Reinstalling fixed it: bin/opencode.exe became a valid PE image (~206 MB, magic MZ), opencode --version reports v2.0.19, and opencode service status responds.
One more artifact from the same update: the reinstall left an orphaned staging directory node_modules/@opencode/.cli-<id> containing a full node_modules tree (~196 MB) that was never cleaned up.
So the failure mode here is not "the old binary stayed in place" but "the installed binary is a postinstall placeholder because the platform optional dependency / postinstall did not run". Reporting it here because the trigger surface (Windows + bun-style install) looks the same.
Thanks for the detailed report and diagnosis. Reproducing this depends on how Windows locks running executables, and our test sandbox is Linux, where a running binary can be replaced, so the failure can't happen there. A maintainer with a Windows machine will need to confirm it.
One thing that may matter: your upgrade was run by 2.0.6. A Windows workaround for upgrading while opencode is running (#50819) first shipped in 2.0.15. Even so, the upgrade command reports success without checking that the binary on your PATH actually changed. If you can, please try again once you're on 2.0.15 or later (for example after closing all opencode processes and reinstalling), then run opencode update --method bun with opencode open and tell us whether opencode --version changes. That would help narrow it down.
Activity
github-actions commentedon Sep 25, 2026
Thanks for updating the issue with the Bug Report description, reproduction steps, and system details!
Veld101 commentedon Sep 29, 2026
Adding a real-world occurrence on Windows (x64) with
2.0.19, in case it helps pin the fix.After updating to
2.0.19,opencodefailed to start at all:What was on disk:
bin/opencode.exewas a 229-byte shell stub, not a PE image:node_modules/@opencode/cli-windows-x64was not installed (onlynode_modules/@opencode/cliwas present), sopostinstall.mjshad nothing to link.npm config get ignore-scriptsreturnedfalse, so this was not npm's global config disabling scripts.D:\Data\npm\globalcontainsbun/bunxshims, so bun may have been involved in the install path; bun does not run dependency lifecycle scripts by default.Reinstalling fixed it:
bin/opencode.exebecame a valid PE image (~206 MB, magicMZ),opencode --versionreportsv2.0.19, andopencode service statusresponds.One more artifact from the same update: the reinstall left an orphaned staging directory
node_modules/@opencode/.cli-<id>containing a fullnode_modulestree (~196 MB) that was never cleaned up.So the failure mode here is not "the old binary stayed in place" but "the installed binary is a postinstall placeholder because the platform optional dependency / postinstall did not run". Reporting it here because the trigger surface (Windows + bun-style install) looks the same.
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report and diagnosis. Reproducing this depends on how Windows locks running executables, and our test sandbox is Linux, where a running binary can be replaced, so the failure can't happen there. A maintainer with a Windows machine will need to confirm it.
One thing that may matter: your upgrade was run by 2.0.6. A Windows workaround for upgrading while opencode is running (#50819) first shipped in 2.0.15. Even so, the upgrade command reports success without checking that the binary on your PATH actually changed. If you can, please try again once you're on 2.0.15 or later (for example after closing all opencode processes and reinstalling), then run
opencode update --method bunwith opencode open and tell us whetheropencode --versionchanges. That would help narrow it down.Related issues:
opencode.exe