Unable to run opencode when node/npm is managed by Volta #134

Open
opened 2026-02-16 17:25:21 -05:00 by yindo · 8 comments
Owner

Originally created by @Traviskn on GitHub (Jun 18, 2025).

Originally assigned to: @thdxr on GitHub.

I use Volta to manage my node version. I am able to install and run claude code via npm without problems. When I install opencode via npm however it is unable to run:

npm i -g opencode-ai@latest
opencode auth login

Volta error: Could not execute command.

See `volta help install` and `volta help pin` for info about making tools available.

I have tried uninstalling and reinstalling with npm and using volta install rather than npm with the same "could not execute command" error. The volta help commands aren't giving me any hints. I'm not quite sure what's going on since other global npm tools work just fine, but wanted to create this issue in case other Volta users run into it.

For now I am installing via Homebrew and opencode works great! Thanks for building this 😄

Originally created by @Traviskn on GitHub (Jun 18, 2025). Originally assigned to: @thdxr on GitHub. I use [Volta](https://volta.sh/) to manage my node version. I am able to install and run claude code via npm without problems. When I install opencode via npm however it is unable to run: ```shell npm i -g opencode-ai@latest opencode auth login Volta error: Could not execute command. See `volta help install` and `volta help pin` for info about making tools available. ``` I have tried uninstalling and reinstalling with npm and using volta install rather than npm with the same "could not execute command" error. The volta help commands aren't giving me any hints. I'm not quite sure what's going on since other global npm tools work just fine, but wanted to create this issue in case other Volta users run into it. For now I am installing via Homebrew and opencode works great! Thanks for building this 😄
Author
Owner

@thdxr commented on GitHub (Jun 18, 2025):

opencode doesn't use node at all it actually gets installed as a single file executable. not sure what volta is trying to do here - it must hook into some process that is being disrupted

@thdxr commented on GitHub (Jun 18, 2025): opencode doesn't use node at all it actually gets installed as a single file executable. not sure what volta is trying to do here - it must hook into some process that is being disrupted
Author
Owner

@thdxr commented on GitHub (Jun 19, 2025):

going to close this for now if someone has insight on how to fix this please leave a comment

@thdxr commented on GitHub (Jun 19, 2025): going to close this for now if someone has insight on how to fix this please leave a comment
Author
Owner

@mrloop commented on GitHub (Jun 24, 2025):

The symbolic links in the opencode install were broken. In the image below the red paths are broken.

opencode-ai/lib/node_modules/opencode-ai/bin/opencode was pointing to a location in a tmp folder .tmpEJcan8/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode and not opencode-ai/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode. Fixing this link and opencode now runs for me

Image

@mrloop commented on GitHub (Jun 24, 2025): The symbolic links in the opencode install were broken. In the image below the red paths are broken. `opencode-ai/lib/node_modules/opencode-ai/bin/opencode` was pointing to a location in a tmp folder `.tmpEJcan8/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode` and not `opencode-ai/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode`. Fixing this link and `opencode` now runs for me ![Image](https://github.com/user-attachments/assets/6cebfef1-8821-4dd4-85a2-62a9687a594d)
Author
Owner

@morgvanny commented on GitHub (Aug 15, 2025):

The package's postinstall script creates a symlink with an absolute path while the package is in a temporary directory during Volta installation. When Volta moves the package to its final location, the symlink becomes broken, pointing to a non-existent temporary path. This makes opencode unusable with Volta.

The postinstall script for the package uses fs.symlinkSync() with an absolute path to create the symlink. When Volta installs global packages, it:

  1. Installs to a temporary directory first (e.g., ~/.volta/tmp/image/packages/.tmpwVekLa/)
  2. Runs postinstall scripts (symlink created with absolute path to temp dir)
  3. Moves the package to its final location (~/.volta/tools/image/packages/opencode-ai/)
  4. The symlink remains pointing to the now-deleted temporary directory

I think changing it to a relative path instead would work, because the symlink would be preserved when volta moves the directory. If we update postinstall.mjs and change this line:

// OLD - creates absolute path symlink
fs.symlinkSync(binaryPath, binScript);

// NEW - creates relative path symlink
fs.symlinkSync(path.relative(path.dirname(binScript), binaryPath), binScript);

That may fix it, if I'm not mistaken.

@morgvanny commented on GitHub (Aug 15, 2025): The package's postinstall script creates a symlink with an absolute path while the package is in a temporary directory during Volta installation. When Volta moves the package to its final location, the symlink becomes broken, pointing to a non-existent temporary path. This makes opencode unusable with Volta. The postinstall script for the package uses `fs.symlinkSync()` with an absolute path to create the symlink. When Volta installs global packages, it: 1. Installs to a temporary directory first (e.g., `~/.volta/tmp/image/packages/.tmpwVekLa/`) 2. Runs postinstall scripts (symlink created with absolute path to temp dir) 3. Moves the package to its final location (`~/.volta/tools/image/packages/opencode-ai/`) 4. The symlink remains pointing to the now-deleted temporary directory I think changing it to a relative path instead would work, because the symlink would be preserved when volta moves the directory. If we update `postinstall.mjs` and change this line: ```javascript // OLD - creates absolute path symlink fs.symlinkSync(binaryPath, binScript); // NEW - creates relative path symlink fs.symlinkSync(path.relative(path.dirname(binScript), binaryPath), binScript); ``` That may fix it, if I'm not mistaken.
Author
Owner

@mrloop commented on GitHub (Aug 17, 2025):

Thanks @morgvanny fix working for me 🎉 https://github.com/sst/opencode/pull/2014

@mrloop commented on GitHub (Aug 17, 2025): Thanks @morgvanny fix working for me :tada: https://github.com/sst/opencode/pull/2014
Author
Owner

@adonh commented on GitHub (Oct 5, 2025):

plx fix in the default post-install script. TY!

@adonh commented on GitHub (Oct 5, 2025): plx fix in the default post-install script. TY!
Author
Owner

@rekram1-node commented on GitHub (Oct 6, 2025):

hm ill take a look

@rekram1-node commented on GitHub (Oct 6, 2025): hm ill take a look
Author
Owner

@synappsysai commented on GitHub (Nov 4, 2025):

I'm still facing the problem, I installed the latest version through Volta:

(base) <user>@<user>s-Mac-Studio ~ % cd ~/.volta/tools/image/packages/opencode-ai/
(base) <user>@<user>s-Mac-Studio opencode-ai % ls -l
total 0
drwxr-xr-x  3 <user>  staff  96 Nov  4 16:57 bin
drwxr-xr-x  3 <user>  staff  96 Nov  4 16:57 lib
(base) <user>@<user>s-Mac-Studio opencode-ai % cd bin
(base) <user>@<user>s-Mac-Studio bin % ls -l opencode
lrwxr-xr-x  1 <user>  staff  44 Nov  4 16:57 opencode -> ../lib/node_modules/opencode-ai/bin/opencode
(base) <user>@<user>s-Mac-Studio bin % ls -l ../lib/node_modules/opencode-ai/bin/opencode
lrwxr-xr-x  1 <user>  staff  126 Nov  4 16:57 ../lib/node_modules/opencode-ai/bin/opencode -> /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode
(base) <user>@<user>s-Mac-Studio bin % 
(base) <user>@<user>s-Mac-Studio bin % 
(base) <user>@<user>s-Mac-Studio bin % ls -l /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode
ls: /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode: No such file or directory
(base) <user>@<user>s-Mac-Studio bin % 
@synappsysai commented on GitHub (Nov 4, 2025): I'm still facing the problem, I installed the latest version through Volta: ``` (base) <user>@<user>s-Mac-Studio ~ % cd ~/.volta/tools/image/packages/opencode-ai/ (base) <user>@<user>s-Mac-Studio opencode-ai % ls -l total 0 drwxr-xr-x 3 <user> staff 96 Nov 4 16:57 bin drwxr-xr-x 3 <user> staff 96 Nov 4 16:57 lib (base) <user>@<user>s-Mac-Studio opencode-ai % cd bin (base) <user>@<user>s-Mac-Studio bin % ls -l opencode lrwxr-xr-x 1 <user> staff 44 Nov 4 16:57 opencode -> ../lib/node_modules/opencode-ai/bin/opencode (base) <user>@<user>s-Mac-Studio bin % ls -l ../lib/node_modules/opencode-ai/bin/opencode lrwxr-xr-x 1 <user> staff 126 Nov 4 16:57 ../lib/node_modules/opencode-ai/bin/opencode -> /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode (base) <user>@<user>s-Mac-Studio bin % (base) <user>@<user>s-Mac-Studio bin % (base) <user>@<user>s-Mac-Studio bin % ls -l /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode ls: /Users/<user>/.volta/tmp/image/packages/.tmpVbIcJj/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode: No such file or directory (base) <user>@<user>s-Mac-Studio bin % ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#134