Skip to content

fix(cli): reject stale platform binaries during install - #53845

Merged
thdxr merged 1 commit into
v2from
postinstall-version
Oct 8, 2026
Merged

thdxr merged 1 commit into
v2from
postinstall-version

Conversation

@thdxr

@thdxr thdxr commented Oct 8, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Closes #

Type of change

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

What does this PR do?

opencode upgrade could report success while leaving the previous release installed. When a platform package version (e.g. @opencode/cli-linux-x64@0.0.0-dev-20719) was not yet visible on npm, Bun skipped the optional dependency, kept the old platform package directory, and exited 0. The postinstall script then picked that package by name, saw its binary run, and linked the old binary under the new launcher.

The postinstall script now rejects a platform package whose version does not match the launcher's optionalDependencies, so it falls through to the next candidate (for example the baseline build) or to its npm fallback. If nothing matches, it exits 1, the package manager fails, and opencode upgrade reports the failure.

How did you verify your code works?

  • On a copy of a real install stuck in this state (launcher 20719, cli-linux-x64 20718): the old script kept 20718; the patched script skipped the stale package and linked cli-linux-x64-baseline@0.0.0-dev-20719, and the binary reported 20719.
  • With no matching platform package, the script exits 1 with the existing "Failed to install OpenCode" message.
  • Confirmed bun install --global --trust exits 1 when a postinstall script fails.
  • bun run check passes.

Screenshots / recordings

N/A

Checklist

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

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr
thdxr merged commit 6861df7 into v2 Oct 8, 2026
@thdxr
thdxr deleted the postinstall-version branch October 8, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant