opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Error if Node version is pinned in Homebrew

Open romado77 opened this issue 2 months ago • 4 comments

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

  1. Uninstall current Node with brew uninstall --ignore-dependencies node
  2. Install node with brew brew install node@24.
  3. Run opencode

Screenshot and/or share link

No response

Operating System

macOS 15.7.3

Terminal

Ghostty

romado77 avatar Dec 23 '25 11:12 romado77

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.

github-actions[bot] avatar Dec 23 '25 11:12 github-actions[bot]

opencode doesnt require node to run I guess this would be a bug with the homebrew formula that the homebrew team maintains?

rekram1-node avatar Dec 23 '25 14:12 rekram1-node

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?

romado77 avatar Dec 23 '25 15:12 romado77

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

rekram1-node avatar Dec 23 '25 15:12 rekram1-node

Any updates on this? Still happening with opencode 1.1.50.

vladimirven001 avatar Feb 11 '26 20:02 vladimirven001

@vladimirven001 use our homebrew tap instead: brew install anomalyco/tap/opencode

rekram1-node avatar Feb 11 '26 21:02 rekram1-node