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
npm 12 upgrade leaves the Windows executable stub #51553
opencode upgrade can report success with npm 12 while leaving the published text stub in bin/opencode.exe. The next invocation fails on Windows because the file is not a valid executable.
The updater runs npm install --global --force without allowing the target package's lifecycle scripts. npm 12 can block postinstall and still exit 0, even with ignore-scripts=false. Adding --allow-scripts=@opencode/cli lets postinstall replace the stub.
I reproduced that policy behavior with a synthetic package in an isolated Windows install prefix using npm 12.0.2 and Node 24.21.0. The flag also preserved explicit ignore-scripts=true. This report covers the updater command; #48884 covers the broader packaging behavior when scripts are disabled.
OpenCode version
Reported on the upgrade from 2.0.16 to 2.0.18.
Steps to reproduce
Start with a working npm installation of OpenCode 2.0.16 and npm 12.0.2, with ignore-scripts=false and no script approval for @opencode/cli.
Run opencode upgrade 2.0.18 using the npm method.
Run opencode --version.
The upgrade reports success, but Windows rejects bin/opencode.exe. Running the installed package's postinstall.mjs manually repairs it.
Windows: self-update can brick the install (postinstall blocked + self-locked binary)
Windows 11 25H2 (26200), npm 12.1.0, Node v24.19.0, [email protected] installed globally. No manual upgrade was run — the running opencode triggered its own npm install -g at launch, and the result was a permanently unlaunchable install.
What happens, in order:
13:31:59 opencode.exe PID 16312 starts
13:32:02 5 MCP child processes
13:32:09 npm install -g [email protected] <- triggered by opencode itself
npm warn cleanup EPERM ... unlink
'...\.opencode-ai-9qjAHli1\node_modules\opencode-windows-x64\bin\opencode.exe'
npm warn install-scripts 1 package had install scripts blocked
because they are not covered by allowScripts:
[email protected] (postinstall: node ./postinstall.mjs)
13:32:20 bin/opencode.exe = 479 bytes (text stub)
npm exits 0 and reports info ok. The install is silently broken.
Afterwards every launch fails:
opencode.exe : Указанный исполняемый файл не является действительным
приложением для этой операционной системы.
opencode.ps1:14 & "$basedir/node_modules/opencode-ai/bin/opencode.exe" $args
NativeCommandFailed
autoupdate defaults to true, so opencode runs npm install -g against itself while its own .exe is loaded. That produces the EPERM on unlink. The EPERM itself is harmless (npm only fails to delete the stale .opencode-ai-<hash> directory) — but combined with cause 1, the running process turns a routine self-update into a bricked install.
The combination is the part I don't see covered.#51553 describes the updater leaving the stub; #50819 (merged 2026-09-23) fixes Windows upgrades fighting the running binary — but it's merged into the v2 branch. npm dist-tag latest is still 1.18.34 on the 1.x line, so the fix isn't reachable for anyone installing from latest, and #50819 doesn't address that autoupdate: true is what initiates the update from inside the locked process in the first place.
Happy to backport-test if a 1.x fix or a release note is warranted.
Workaround in use until this is fixed
opencode.jsonc: "autoupdate": "notify". The config schema allows true | false | "notify", but "notify" only appears in the schema description, not in the published config docs — I had to read the schema to find it. Since true is the default and true is what triggers the in-process self-update, "notify" looks like a safer default on Windows specifically.
npm config set allow-scripts=opencode-ai --location=user
A PATH shim that validates bin/opencode.exe (size + MZ signature) and repairs via node postinstall.mjs if it's the stub, then defers the update check to an exit hook where no process holds the .exe.
Two smaller notes
package.json has no repository/bugs field, so tooling can't discover the tracker automatically.
npm 12 exiting 0 after install-scripts blocked makes this hard to detect from scripts or CI. A non-zero exit, or a stderr warning that isn't warn-level, would surface it much sooner.
This is not Windows-specific. On macOS the stub is a shell script, so instead of an invalid-executable error, every invocation prints the postinstall error:
Error: @opencode/cli's postinstall script was not run.
This occurs when installation scripts are disabled.
Run the package postinstall script or reinstall with scripts enabled.
Environment: macOS arm64, Node 24.21.0, @opencode/cli 2.0.22 upgrading to 2.0.23. I ran it in an isolated prefix with a fresh HOME, npm cache and npmrc, and no allow-scripts configured:
The updater's command, npm install --global --force @opencode/[email protected], exits 0 under npm 12.0.2 with only this warning:
npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts @opencode/[email protected] (postinstall: node ./postinstall.mjs)
The same failure first appeared on a regular npm install upgraded under npm 12.0.2. From the broken state, either of these restored a working 2.0.23:
node ./postinstall.mjs in the installed package directory
On the v2 branch at 88dd4417c7e9, packages/cli/src/services/updater.ts still passes no allow flag to npm, though pnpm gets --allow-build and bun gets --trust. #51554 covers this case on macOS too. Separately, it might be worth having opencode upgrade check that the new binary actually runs before printing Upgrade complete.
Confirming this on 2.0.30 with npm 12.0.2 (Windows 11, global npm install channel):
opencode upgrade reports success (From 2.0.29 → 2.0.30) but bin\opencode.exe is left as the 229-byte stub, so opencode --version fails with "The specified executable is not a valid application for this OS platform".
The platform packages are installed correctly at 2.0.30 (@opencode/cli-windows-x64 and @opencode/cli-windows-x64-baseline, both containing a valid 213,522,824-byte bin\opencode.exe), so only the postinstall link step is skipped.
npm config get ignore-scripts is false here, and there is no ignore-scripts=true in the user or global npmrc.
Workaround without reinstalling: cd "$env:APPDATA\npm\node_modules\@opencode\cli"; node postinstall.mjs — this produces a working 213,522,824-byte launcher.
Windows + npm 12.2.0 data point, plus the persistent-config answer.
Same failure, end to end. Windows 11 (10.0.26300.9711), Node 24.21.0, npm 12.2.0, @opencode/cli 2.0.30, global npm install, channel latest. Update was triggered from the TUI with /update, so the npm install ran from inside the already-running process; it reported success, but the first launch afterwards failed. bin\opencode.exe had been left as the 229-byte stub. npm config get ignore-scripts is false and there is no allowScripts entry anywhere, so nothing is opting out explicitly - this is npm 12's default. That extends the Windows 12.0.2 data above to 12.2.0.
Confirmed workaround, no uninstall needed. Re-running the same global install with the flag repaired the broken install in place:
npm i -g @opencode/cli --allow-scripts=@opencode/cli
No uninstall and no clean prefix was required - the postinstall simply replaced the stub. Running node postinstall.mjs in the installed package directory also repairs it without going through npm.
Persistent config instead of a per-invocation flag. Repeating --allow-scripts=@opencode/cli on every install and update is easy to forget. npm documents that flag as the route for -g / npx (there is no project package.json for npm approve-scripts, which fails with EGLOBAL), and npm config set as the persistent form:
npm config set allow-scripts=@opencode/cli --location=user
I have not tested that end-to-end, but it follows from the documented npm behaviour, and it answers the question asked on #51554. A line in the docs or troubleshooting page would turn "remember the flag on every update" into one-time setup.
Docs gap on the install page.https://opencode.ai/v2/docs currently lists bun install -g --trust @opencode/cli, pnpm add -g --allow-build=@opencode/cli, and then a bare npm install -g @opencode/cli. On npm 12 that last command produces an install that cannot run. The npm entry should carry --allow-scripts=@opencode/cli as well, and troubleshooting should mention the no-reinstall repair:
cd "$(npm root -g)/@opencode/cli" && node postinstall.mjs
# Windows:
cd "$env:APPDATA\npm\node_modules\@opencode\cli"; node postinstall.mjs
Root cause worth reviving. The updater fix is #51554. The packaging fix that removes the postinstall dependency altogether is the runtime launcher in #48885, which was auto-closed by the PR cleanup on 2026-10-14 while #48884 is still open. It seems worth judging on its merits rather than letting it age out.
That file was only 229 bytes and did not have a valid Windows executable header. The matching platform packages, @opencode/[email protected] and @opencode/[email protected], were both present and contained valid Windows executables, each 218,766,376 bytes.
The CLI package defines a postinstall script that selects and copies the platform executable into bin\opencode.exe. The evidence suggests that this step did not run during /update, leaving the small placeholder file in place.
I repaired the installation without uninstalling it by running this from the package directory:
cd C:\nvm4w\nodejs\node_modules\@opencode\cli
node .\postinstall.mjs
Content is the postinstall-failure echo script, not a PE binary.
2. The real binary was truncated
%APPDATA%\npm\node_modules\@opencode\cli\node_modules\@opencode\cli-windows-x64\bin\opencode.exe
actual 149,712,037 bytes
expected 246,919,797 bytes (registry dist.unpackedSize)
The header is a valid MZ / PE\0\0 / x64 / PE32+, so it is not a format problem — the file simply stops short. Executing it returns The specified executable is not a valid application for this OS platform.
These are npm's in-flight temp names. The rename to opencode.cmd never happened, which is why PATH has no opencode at all.
4. ignore-scripts is false
PS> npm config get ignore-scripts
false
Why this is worth a look
I cannot tell from the user side whether npm skipped the postinstall or the extraction was interrupted — but both end in the same state: a text stub, temp shims, a truncated binary, and a command not found error that points at "not installed" instead of "installed corrupt".
That is the part that cost time: the reported symptom and the actual cause are unrelated.
It also suggests the #51554 fix may need to cover more than the upgrade path, and npm 11 as well as 12.
Thanks for the detailed report. I could reproduce this, and it isn't specific to Windows: the published bin/opencode.exe is a stub on every platform until postinstall replaces it.
Steps (on Linux, npm 12.0.2, Node 24.21.0, isolated global prefix, ignore-scripts=false, no allow-scripts config):
Install a working @opencode/[email protected] (scripts allowed once); opencode --version prints v2.0.16.
Run opencode upgrade --method npm 2.0.18. It prints "Upgrade complete" and exits 0.
Run opencode --version. It fails with @opencode/cli's postinstall script was not run. package.json says 2.0.18, but bin/opencode.exe is still the stub.
Running the same install by hand with --allow-scripts=@opencode/cli gives a working 2.0.18. The npm command in the updater on the latest dev (86ce19d) still has no such flag, while pnpm (--allow-build) and bun (--trust) already get one. Upgrading with the latest release (2.2.0) fails the same way.
The script below reproduces it. Related: #48884, the broader issue of the package not working when install scripts are disabled.
Reproduction script (repro.sh)
#!/usr/bin/env bash# Reproduces #51553 on Linux: with npm 12, `opencode upgrade` (npm method) exits 0# but npm blocks @opencode/cli's postinstall, leaving the bin/opencode.exe stub.# Set OC_DEV=/path/to/checkout to run the upgrade command from source instead.set -u
W=/tmp/opencode/r51553; rm -rf "$W"; mkdir -p "$W/npm12""$W/npmbin""$W/pfx""$W/home"
(cd "$W/npm12"&& npm install --silent [email protected]>/dev/null 2>&1)
ln -sf "$W/npm12/node_modules/.bin/npm""$W/npmbin/npm"export PATH="$W/pfx/bin:$W/npmbin:$PATH" npm_config_prefix="$W/pfx" HOME="$W/home"echo"npm $(npm --version); ignore-scripts=$(npm config get ignore-scripts)"# Working 2.0.16 install (scripts explicitly allowed once).
npm install --global --allow-scripts=@opencode/cli @opencode/[email protected]>/dev/null 2>&1echo"before: $(opencode --version)"cd"$W"if [ -n"${OC_DEV:-}" ];then
bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" \
"$OC_DEV/packages/cli/src/index.ts" upgrade --method npm 2.0.18 2>&1| tr '\r''\n'| grep -E "Using|From|complete|Done|rror";echo"upgrade exit=${PIPESTATUS[0]}"else
opencode upgrade --method npm 2.0.18 2>&1| tr '\r''\n'| grep -E "Using|From|complete|Done|rror";echo"upgrade exit=${PIPESTATUS[0]}"fiecho"installed package.json version: $(node -p "require('$W/pfx/lib/node_modules/@opencode/cli/package.json').version")"echo"--- opencode --version after upgrade:"
opencode --version;echo"exit=$?"echo"--- bin/opencode.exe head:"; head -c 80 "$W/pfx/lib/node_modules/@opencode/cli/bin/opencode.exe";echo
npm: 12.2.1, ignore-scripts=false, no ignore-scripts in user or global npmrc
Install: global npm at %APPDATA%\npm\node_modules\@opencode\cli
Active plugins: one local plugin (mempalace-bootstrap)
Reproduction
Working global npm install of @opencode/[email protected]; opencode --version prints opencode v2.2.2.
Run opencode upgrade. It prints Using method: npm, From 2.2.2 → 2.2.5, Upgrade complete, and exits 0.
Run opencode --version. It fails immediately:
Program 'opencode.exe' failed to run: The specified executable is not a valid application for this OS platform.
%APPDATA%\npm\node_modules\@opencode\cli\bin\opencode.exe is left as the 229-byte tarball stub:
echo "Error: @opencode/cli's postinstall script was not run." >&2
...
exit 1
The optional platform packages installed correctly at 2.2.5 (@opencode/cli-windows-x64\bin\opencode.exe = 259,169,160 bytes), so this is only the missing postinstall hardlink/copy step.
Evidence the described fix is not present in 2.2.5
The shipped 2.2.5 binary does not contain the literal --allow-scripts, while other updater strings are present. Calibrated with rg -a -F over bin/opencode.exe (259,169,160 bytes):
string
result
Upgrade complete
found
Using method
found
postinstall
found
npm_execpath
found
--force
found
ignore-scripts
found
--allow-scripts
not found
So the npm method still does not receive the flag that pnpm (--allow-build) and bun (--trust) already get, and an upgrade performed from 2.2.2 still produces the stub with exit code 0.
Manual recovery worked here (relevant to #56380, which reports the recommended recovery cannot work on Windows):
cd "$env:APPDATA\npm\node_modules\@opencode\cli"
node postinstall.mjs # exit 0
Afterwards bin\opencode.exe is 259,169,160 bytes and fsutil hardlink list shows it linked to cli-windows-x64\bin\opencode.exe (so no extra disk cost). opencode --version then prints opencode v2.2.5.
It succeeded because the platform package was already installed: resolveBinary() + copyBinary() satisfied the loop, and installPackage() — the only path that spawns npm and therefore the only one that can hit ENOENT — was never reached. The recovery appears to fail only when the platform package must actually be fetched.
Impact
A user on any pre-fix version who upgrades to the current release loses a runnable CLI, and the upgrade reports success with exit code 0. The only hint is the stub's own text, which contradicts the success banner.
Activity
github-actions commentedon Sep 26, 2026
This issue might be related to existing reports. Please check:
linko22 commentedon Oct 1, 2026
Windows: self-update can brick the install (postinstall blocked + self-locked binary)
Windows 11 25H2 (26200), npm 12.1.0, Node v24.19.0,
[email protected]installed globally. No manual upgrade was run — the running opencode triggered its ownnpm install -gat launch, and the result was a permanently unlaunchable install.What happens, in order:
npm exits 0 and reports
info ok. The install is silently broken.Afterwards every launch fails:
Two independent causes, neither sufficient alone:
npm 12 blocks
postinstallby default unless the package is inallowScripts.bin/opencode.exein the published tarball is a 479-byte text stub thatpostinstall.mjsis supposed to replace. Block the script and the stub ships as-is. npm still exits 0. Already tracked in npm 12 upgrade leaves the Windows executable stub #51553 and Windows: postinstall fails to copy binary from optionalDependency — stub remains 479 bytes #41370; the--allow-scriptsworkaround works.autoupdatedefaults totrue, so opencode runsnpm install -gagainst itself while its own.exeis loaded. That produces theEPERMon unlink. The EPERM itself is harmless (npm only fails to delete the stale.opencode-ai-<hash>directory) — but combined with cause 1, the running process turns a routine self-update into a bricked install.The combination is the part I don't see covered. #51553 describes the updater leaving the stub; #50819 (merged 2026-09-23) fixes Windows upgrades fighting the running binary — but it's merged into the
v2branch.npm dist-tag latestis still1.18.34on the1.xline, so the fix isn't reachable for anyone installing fromlatest, and #50819 doesn't address thatautoupdate: trueis what initiates the update from inside the locked process in the first place.Happy to backport-test if a
1.xfix or a release note is warranted.Workaround in use until this is fixed
opencode.jsonc:"autoupdate": "notify". The config schema allowstrue | false | "notify", but"notify"only appears in the schema description, not in the published config docs — I had to read the schema to find it. Sincetrueis the default andtrueis what triggers the in-process self-update,"notify"looks like a safer default on Windows specifically.npm config set allow-scripts=opencode-ai --location=userbin/opencode.exe(size +MZsignature) and repairs vianode postinstall.mjsif it's the stub, then defers the update check to an exit hook where no process holds the.exe.Two smaller notes
package.jsonhas norepository/bugsfield, so tooling can't discover the tracker automatically.install-scripts blockedmakes this hard to detect from scripts or CI. A non-zero exit, or a stderr warning that isn'twarn-level, would surface it much sooner.coygeek commentedon Oct 5, 2026
Also reproduces on macOS arm64 (2.0.22 → 2.0.23)
This is not Windows-specific. On macOS the stub is a shell script, so instead of an invalid-executable error, every invocation prints the postinstall error:
Environment: macOS arm64, Node 24.21.0,
@opencode/cli2.0.22 upgrading to 2.0.23. I ran it in an isolated prefix with a freshHOME, npm cache and npmrc, and noallow-scriptsconfigured:npm install --global --allow-scripts=@opencode/cli @opencode/[email protected], thenopencode --versionprintedopencode v2.0.22.opencode upgrade 2.0.23 --method npmopencode --versionandopencode2 --versionUsing method: npm,Upgrade complete, exit 0latest)Upgrade complete, exit 0Upgrade complete, exit 0opencode v2.0.23, exit 0The updater's command,
npm install --global --force @opencode/[email protected], exits 0 under npm 12.0.2 with only this warning:The same failure first appeared on a regular npm install upgraded under npm 12.0.2. From the broken state, either of these restored a working 2.0.23:
node ./postinstall.mjsin the installed package directorynpm install --global --force --allow-scripts=@opencode/cli @opencode/[email protected]On the
v2branch at88dd4417c7e9,packages/cli/src/services/updater.tsstill passes no allow flag to npm, though pnpm gets--allow-buildand bun gets--trust. #51554 covers this case on macOS too. Separately, it might be worth havingopencode upgradecheck that the new binary actually runs before printingUpgrade complete.baize-1-heic commentedon Oct 15, 2026
Confirming this on 2.0.30 with npm 12.0.2 (Windows 11, global npm install channel):
opencode upgradereports success (From 2.0.29 → 2.0.30) butbin\opencode.exeis left as the 229-byte stub, soopencode --versionfails with "The specified executable is not a valid application for this OS platform".@opencode/cli-windows-x64and@opencode/cli-windows-x64-baseline, both containing a valid 213,522,824-bytebin\opencode.exe), so only the postinstall link step is skipped.npm config get ignore-scriptsisfalsehere, and there is noignore-scripts=truein the user or global npmrc.cd "$env:APPDATA\npm\node_modules\@opencode\cli"; node postinstall.mjs— this produces a working 213,522,824-byte launcher.GuzhouYiyun commentedon Oct 16, 2026
Windows + npm 12.2.0 data point, plus the persistent-config answer.
Same failure, end to end. Windows 11 (10.0.26300.9711), Node 24.21.0, npm 12.2.0,
@opencode/cli2.0.30, global npm install, channellatest. Update was triggered from the TUI with/update, so the npm install ran from inside the already-running process; it reported success, but the first launch afterwards failed.bin\opencode.exehad been left as the 229-byte stub.npm config get ignore-scriptsisfalseand there is noallowScriptsentry anywhere, so nothing is opting out explicitly - this is npm 12's default. That extends the Windows 12.0.2 data above to 12.2.0.Confirmed workaround, no uninstall needed. Re-running the same global install with the flag repaired the broken install in place:
No uninstall and no clean prefix was required - the postinstall simply replaced the stub. Running
node postinstall.mjsin the installed package directory also repairs it without going through npm.Persistent config instead of a per-invocation flag. Repeating
--allow-scripts=@opencode/clion every install and update is easy to forget. npm documents that flag as the route for-g/npx(there is no projectpackage.jsonfornpm approve-scripts, which fails withEGLOBAL), andnpm config setas the persistent form:I have not tested that end-to-end, but it follows from the documented npm behaviour, and it answers the question asked on #51554. A line in the docs or troubleshooting page would turn "remember the flag on every update" into one-time setup.
Docs gap on the install page. https://opencode.ai/v2/docs currently lists
bun install -g --trust @opencode/cli,pnpm add -g --allow-build=@opencode/cli, and then a barenpm install -g @opencode/cli. On npm 12 that last command produces an install that cannot run. The npm entry should carry--allow-scripts=@opencode/clias well, and troubleshooting should mention the no-reinstall repair:Root cause worth reviving. The updater fix is #51554. The packaging fix that removes the postinstall dependency altogether is the runtime launcher in #48885, which was auto-closed by the PR cleanup on 2026-10-14 while #48884 is still open. It seems worth judging on its merits rather than letting it age out.
shehryaraijaz commentedon Oct 20, 2026
I’m seeing the same issue on a newer OpenCode 2 release.
Environment:
I started with a working v2.0.30 installation and ran
/updatefrom the TUI. The update reported success, but afterward, runningopencodefailed with:PowerShell showed that
opencode.ps1was trying to run:That file was only 229 bytes and did not have a valid Windows executable header. The matching platform packages,
@opencode/[email protected]and@opencode/[email protected], were both present and contained valid Windows executables, each 218,766,376 bytes.The CLI package defines a postinstall script that selects and copies the platform executable into
bin\opencode.exe. The evidence suggests that this step did not run during/update, leaving the small placeholder file in place.I repaired the installation without uninstalling it by running this from the package directory:
Afterward,
opencode --versionreportedopencode v2.1.1.I also configured npm to allow the package’s install script:
BingWuJ commentedon Oct 24, 2026
Reproduced on npm 11.6.2 and this is not limited to npm 12.
Environment
Symptoms
opencodeis not resolvable at all:No partial install warning, no repair hint.
Evidence
1.
bin/opencode.exeis the 229-byte text stubContent is the postinstall-failure echo script, not a PE binary.
2. The real binary was truncated
The header is a valid
MZ/PE\0\0/ x64 / PE32+, so it is not a format problem — the file simply stops short. Executing it returnsThe specified executable is not a valid application for this OS platform.3. npm shims never got their final names
These are npm's in-flight temp names. The rename to
opencode.cmdnever happened, which is why PATH has noopencodeat all.4.
ignore-scriptsis falseWhy this is worth a look
I cannot tell from the user side whether npm skipped the postinstall or the extraction was interrupted — but both end in the same state: a text stub, temp shims, a truncated binary, and a
command not founderror that points at "not installed" instead of "installed corrupt".That is the part that cost time: the reported symptom and the actual cause are unrelated.
It also suggests the #51554 fix may need to cover more than the upgrade path, and npm 11 as well as 12.
Recovery that worked
Completed in 40s,
bin/opencode.exebecame 246,919,560 bytes,opencode v2.1.4works.Note: cleaning only the package directory is not enough — the stale temp shims must go too, otherwise the reinstall leaves a half-registered command.
Suggestions
bin/opencode.exeis larger than the stub (or matches the platform package's expected size) and fail loudly if not.command not found..opencode*temp shims before creating new ones.opencodejr commentedon Oct 28, 2026
Thanks for the detailed report. I could reproduce this, and it isn't specific to Windows: the published
bin/opencode.exeis a stub on every platform untilpostinstallreplaces it.Steps (on Linux, npm 12.0.2, Node 24.21.0, isolated global prefix,
ignore-scripts=false, noallow-scriptsconfig):@opencode/[email protected](scripts allowed once);opencode --versionprints v2.0.16.opencode upgrade --method npm 2.0.18. It prints "Upgrade complete" and exits 0.opencode --version. It fails with@opencode/cli's postinstall script was not run.package.jsonsays 2.0.18, butbin/opencode.exeis still the stub.Running the same install by hand with
--allow-scripts=@opencode/cligives a working 2.0.18. The npm command in the updater on the latestdev(86ce19d) still has no such flag, while pnpm (--allow-build) and bun (--trust) already get one. Upgrading with the latest release (2.2.0) fails the same way.The script below reproduces it. Related: #48884, the broader issue of the package not working when install scripts are disabled.
Reproduction script (repro.sh)
Run it:
bash repro.shdeathman915-sys commentedon Nov 2, 2026
Still reproducing after this was closed, on the current release.
Environment
opencode upgrade(method npm), 2.2.2 → 2.2.5ignore-scripts=false, noignore-scriptsin user or global npmrc%APPDATA%\npm\node_modules\@opencode\climempalace-bootstrap)Reproduction
@opencode/[email protected];opencode --versionprintsopencode v2.2.2.opencode upgrade. It printsUsing method: npm,From 2.2.2 → 2.2.5,Upgrade complete, and exits 0.opencode --version. It fails immediately:%APPDATA%\npm\node_modules\@opencode\cli\bin\opencode.exeis left as the 229-byte tarball stub:The optional platform packages installed correctly at 2.2.5 (
@opencode/cli-windows-x64\bin\opencode.exe= 259,169,160 bytes), so this is only the missing postinstall hardlink/copy step.Evidence the described fix is not present in 2.2.5
The shipped 2.2.5 binary does not contain the literal
--allow-scripts, while other updater strings are present. Calibrated withrg -a -Foverbin/opencode.exe(259,169,160 bytes):Upgrade completeUsing methodpostinstallnpm_execpath--forceignore-scripts--allow-scriptsSo the npm method still does not receive the flag that pnpm (
--allow-build) and bun (--trust) already get, and an upgrade performed from 2.2.2 still produces the stub with exit code 0.Manual recovery worked here (relevant to #56380, which reports the recommended recovery cannot work on Windows):
Afterwards
bin\opencode.exeis 259,169,160 bytes andfsutil hardlink listshows it linked tocli-windows-x64\bin\opencode.exe(so no extra disk cost).opencode --versionthen printsopencode v2.2.5.It succeeded because the platform package was already installed:
resolveBinary()+copyBinary()satisfied the loop, andinstallPackage()— the only path that spawns npm and therefore the only one that can hitENOENT— was never reached. The recovery appears to fail only when the platform package must actually be fetched.Impact
A user on any pre-fix version who upgrades to the current release loses a runnable CLI, and the upgrade reports success with exit code 0. The only hint is the stub's own text, which contradicts the success banner.