Description
On Windows, bun run <script> inside an opencode session resolves tools like vitest, vue-tsc, eslint, etc. to opencode.exe instead of the actual tool binary in node_modules/.bin/.
Root cause: When node is not on PATH, bun auto-creates a node symlink pointing to the current process executable. Since opencode is a bun --compile standalone, that symlink points to opencode.exe. Any tool with a #!/usr/bin/env node shebang then executes opencode instead of the JS runtime.
Why Claude Code doesn't have this problem: Claude Code's claude.exe overrides the compiled binary metadata (ProductName: Claude Code, blank OriginalFilename). opencode ships with stock bun metadata:
| Field |
Claude Code |
opencode |
ProductName |
Claude Code |
Bun |
OriginalFilename |
(empty) |
bun.exe |
FileDescription |
Claude Code |
Bun |
CompanyName |
Anthropic PBC |
Oven |
Verified via (Get-Item opencode.exe).VersionInfo on Windows.
Suggested fix: Customize the exe metadata in the bun build --compile step, similar to how Claude Code does it, so bun's runtime doesn't identify the opencode binary as a bun instance.
Steps to reproduce
- Install opencode on Windows via winget (no Node.js on PATH)
- Open an opencode session in a project with vitest (or any node-shimmed tool)
- Run
bun run test (where the script calls vitest)
- Observe the opencode help/banner output instead of vitest running
Running node_modules/.bin/vitest.exe directly works fine. The issue is only when bun's shell resolves the binary via the auto-created node symlink.
Operating System
Windows 11
Terminal
Windows Terminal (PowerShell 7.x)
OpenCode version
1.2.15 (bun 1.3.10)
Description
On Windows,
bun run <script>inside an opencode session resolves tools likevitest,vue-tsc,eslint, etc. toopencode.exeinstead of the actual tool binary innode_modules/.bin/.Root cause: When
nodeis not on PATH, bun auto-creates anodesymlink pointing to the current process executable. Since opencode is a bun--compilestandalone, that symlink points toopencode.exe. Any tool with a#!/usr/bin/env nodeshebang then executes opencode instead of the JS runtime.Why Claude Code doesn't have this problem: Claude Code's
claude.exeoverrides the compiled binary metadata (ProductName: Claude Code, blankOriginalFilename). opencode ships with stock bun metadata:ProductNameClaude CodeBunOriginalFilenamebun.exeFileDescriptionClaude CodeBunCompanyNameAnthropic PBCOvenVerified via
(Get-Item opencode.exe).VersionInfoon Windows.Suggested fix: Customize the exe metadata in the
bun build --compilestep, similar to how Claude Code does it, so bun's runtime doesn't identify the opencode binary as a bun instance.Steps to reproduce
bun run test(where the script callsvitest)Running
node_modules/.bin/vitest.exedirectly works fine. The issue is only when bun's shell resolves the binary via the auto-creatednodesymlink.Operating System
Windows 11
Terminal
Windows Terminal (PowerShell 7.x)
OpenCode version
1.2.15 (bun 1.3.10)