Skip to content

fix(core): use platform-aware binary naming in postinstall and publish#28766

Open
lexlian wants to merge 2 commits into
anomalyco:devfrom
lexlian:fix/platform-binary-naming
Open

fix(core): use platform-aware binary naming in postinstall and publish#28766
lexlian wants to merge 2 commits into
anomalyco:devfrom
lexlian:fix/platform-binary-naming

Conversation

@lexlian
Copy link
Copy Markdown

@lexlian lexlian commented May 22, 2026

Issue for this PR

Closes #28639
Closes #28114
Closes #27906

Type of change

  • Bug fix

What does this PR do?

Since v1.15.1, the npm package shipped bin/opencode.exe on all platforms. The postinstall script hardcoded bin/opencode.exe as the target regardless of OS, and the published package's bin field pointed to ./bin/opencode.exe. This caused:

  1. .exe suffix leaking into OS process names on macOS/Linux (tmux window titles show opencode.exe)
  2. bun update -g -i leaving global symlinks stale (symlink pointed to old bin/opencode, new target is bin/opencode.exe)
  3. bin/opencode.exe not executable on Linux when postinstall is skipped

Changes:

  • postinstall.mjs: targetBinary now uses sourceBinary (platform-aware) — bin/opencode on macOS/Linux, bin/opencode.exe on Windows
  • publish.ts: replaces the shell error fallback with a Node.js shim at bin/opencode that delegates to the correct platform binary, and the npm package bin field points to ./bin/opencode

How did you verify your code works?

  • Verified targetBinary resolves to bin/opencode on darwin (inline test)
  • bun typecheck passed in packages/opencode
  • No other callers of the changed code affected (verified via grep)

Screenshots / recordings

N/A — no UI changes.

Checklist

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

Closes anomalyco#28639
Closes anomalyco#28114
Closes anomalyco#27906

The postinstall script hardcoded bin/opencode.exe as the target binary
on all platforms, causing:
- .exe suffix leakage into process names on macOS/Linux (tmux titles)
- Bun global symlink breakage after bun update -g -i
- npm bin field pointing to .exe on all platforms

Fix: postinstall.mjs now uses sourceBinary (platform-aware) for the
target path. publish.ts generates a Node.js shim at bin/opencode that
delegates to the correct platform binary, and the npm package bin
field points to ./bin/opencode (no .exe).
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant