Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Labels
Description
Summary
On Windows with a global npm install, opencode upgrade updates @opencode/cli to the new version but does not run the package's postinstall script, so the launcher bin/opencode.exe is left as the 229-byte placeholder. Every subsequent opencode invocation then fails with "is not a valid application for this OS platform" until the user manually runs node postinstall.mjs.
Environment
- opencode version: upgraded 2.0.29 → 2.0.30 (
opencode upgrade) - OS: Windows 11, 10.0.26200.9711 (win32 x64)
- Terminal:
TERM=xterm-256color;TERM_PROGRAMandCOLORTERMunset - Shell:
C:\WINDOWS\system32\cmd.exe(commands run through PowerShell 5.1.26100.9711) - Install/channel: global npm install (
npm i -g @opencode/cli), channellatest - npm: 12.0.2, registry is a mirror (
registry.npmmirror.com),ignore-scriptsconfig isfalse - Active plugins: none found in config
Reproduction
- On Windows, install OpenCode globally with npm:
npm i -g @opencode/cli(worked fine at 2.0.29). - Run
opencode upgrade. It reportsUsing method: npm,From 2.0.29 → 2.0.30, thenUpgrade complete. - Run
opencode --version.
Expected Behavior
opencode --version prints the new version (opencode v2.0.30).
Actual Behavior
The command fails immediately because the launcher is not an executable:
opencode.exe : 无法启动: 指定的可执行文件不是此操作系统平台的有效应用程序
(ApplicationFailedException: The specified executable is not a valid application for this OS platform)
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
at C:\Users\<user>\AppData\Roaming\npm\opencode.ps1:14 char:3
+ & "$basedir/node_modules/@opencode/cli/bin/opencode.exe" $args
%APPDATA%\npm\node_modules\@opencode\cli\bin\opencode.exe is only 229 bytes and contains the placeholder text shipped in the tarball:
echo "Error: @opencode/cli's postinstall script was not run." >&2
echo "" >&2
echo "This occurs when installation scripts are disabled." >&2
echo "Run the package postinstall script or reinstall with scripts enabled." >&2
exit 1
Additional Context
- The optional platform packages were installed correctly and at the right version, so this is only the missing postinstall hardlink/copy step:
@opencode/cli→ 2.0.30@opencode/cli-windows-x64→ 2.0.30,bin\opencode.exe= 213,522,824 bytes@opencode/cli-windows-x64-baseline→ 2.0.30,bin\opencode.exe= 213,522,824 bytes
npm config get ignore-scripts→false, and noignore-scripts=truein~/.npmrcor the global npmrc, so scripts were not globally disabled by user config.- Workaround that fixed it (no reinstall needed):
After that
cd "$env:APPDATA\npm\node_modules\@opencode\cli" node postinstall.mjsbin\opencode.exebecomes 213,522,824 bytes andopencode --versionprintsopencode v2.0.30. - Likely cause: the npm upgrade path either installs with lifecycle scripts disabled or extracts the package without running them, and never invokes/repairs the
postinstallafterward. The upgrade ends with a success message even though no runnable binary was produced. - Impact: on Windows this leaves OpenCode completely unusable after an upgrade until the user knows to run postinstall manually; the failure message points at an OS/executable problem rather than the real cause.
- Frequency: reproduced on this single 2.0.29 → 2.0.30 upgrade (consistently broken until the manual workaround).
Activity
opencode-agent commentedon Oct 15, 2026
Thanks for the report! Unfortunately the issue body came through as unreadable control characters, but going by the title, I think this is a duplicate of #51553.
Possible duplicates and related issues, ordered from most to least likely:
opencode upgradewith npm 12 blockspostinstall, still reports success and leaves the stubbin/opencode.exe, which Windows rejects. PR fix(cli): allow npm upgrade install scripts #51554 proposes a fix (passing--allow-scripts=@opencode/clito npm).@opencode/clinot running when install scripts are disabled.postinstallnot replacing the 479-byte stub.In the meantime, the workarounds reported in #51553 are:
node ./postinstall.mjsin the installed package directory, ornpm install --global --force --allow-scripts=@opencode/cli @opencode/cli@<version>The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. If it is different, please also include your OpenCode version, npm/Node versions and the exact error you see.
baize-1-heic commentedon Oct 15, 2026
Sorry for the noise at the start — the first version of this body was mangled by the tool I used to post it; it has been rewritten above and is now readable.
Now that the report is readable: this is a duplicate of #51553 (npm 12 upgrade leaves the Windows executable stub), which #51554 is fixing. Closing this one.
For the record, reproduced on 2.0.30 / npm 12.0.2 / Windows 11: after
opencode upgradethe launcherbin\opencode.exeis still the 229-byte stub, while@opencode/cli-windows-x64and@opencode/cli-windows-x64-baselineare installed at 2.0.30 with a valid 213,522,824-bytebin\opencode.exe. Workaround without reinstalling:cd "$env:APPDATA\npm\node_modules\@opencode\cli"; node postinstall.mjs.opencode-agent commentedon Oct 15, 2026
Thanks for rewriting the report and for confirming. Your 2.0.30 / npm 12.0.2 / Windows 11 details match #51553: after the upgrade, the launcher
bin\opencode.exeis still the stub, while the platform package has the real binary. They're a useful data point on a newer version. Runningnode postinstall.mjsin the installed@opencode/clidirectory is the same workaround reported there.Please follow #51553 and PR #51554 for progress. If this issue is still open, the bot will close it as a duplicate.
opencode-agent commentedon Oct 16, 2026
Closing as a duplicate of #51553, as you confirmed. Please follow #51553 and PR #51554 (passes
--allow-scripts=@opencode/clito npm duringopencode upgrade) for progress. Until then, runningnode postinstall.mjsin the installed@opencode/clidirectory replaces the stubopencode.exe. Thanks for the clear 2.0.30 reproduction details.