Error if Node version is pinned in Homebrew
Description
Description
OpenCode depends on Node. Now, Homebrew installs the latest non-LTS Node.js version (25) by default. When Node.js is pinned (for example to node@24), OpenCode fails to start with the following error:
zsh: /opt/homebrew/bin/opencode: bad interpreter: /opt/homebrew/opt/node/bin/node: no such file or directory
Despite this error, the Node binary is available and accessible at: /opt/homebrew/bin/node
OpenCode version
1.0.191
Steps to reproduce
- Uninstall current Node with
brew uninstall --ignore-dependencies node - Install node with brew
brew install node@24. - Run opencode
Screenshot and/or share link
No response
Operating System
macOS 15.7.3
Terminal
Ghostty
This issue might be a duplicate of or related to existing Homebrew/Node.js issues. Please check:
- #5618: Auto-updates not applying correctly in the TUI (Homebrew installation on macOS)
- #4640: Opencode install with brew breaks npm certificates on MacOS (Homebrew installation issues)
- #5176: Install script should use XDG_DATA_HOME for binary location (installation path issues)
The root cause appears to be that the OpenCode shebang line is hardcoded to use /opt/homebrew/opt/node/bin/node, but when Node.js is pinned to a specific version (like node@24), Homebrew installs it to a different path. The binary is accessible at /opt/homebrew/bin/node, but the shebang doesn't find it there.
Feel free to ignore if these don't address your specific case.
opencode doesnt require node to run I guess this would be a bug with the homebrew formula that the homebrew team maintains?
opencode doesnt require node to run I guess this would be a bug with the homebrew formula that the homebrew team maintains?
It's declared in dependencies https://formulae.brew.sh/api/formula/opencode.json.
"dependencies": [
"node",
"ripgrep"
],
Should I raise defect with homebrew to remove node as dependency?
Sure yeah, we ship a single file bun executable so it doesn't have any dep for node.
Now opencode will try to auto install ripgrep if you don't have it installed so I added it to the "official" brew formula since some people complained about this
Any updates on this? Still happening with opencode 1.1.50.
@vladimirven001 use our homebrew tap instead:
brew install anomalyco/tap/opencode