opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open Traviskn opened this issue 5 months ago • 8 comments
trafficstars

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 😄

Traviskn avatar Jun 18 '25 23:06 Traviskn

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 avatar Jun 19 '25 03:06 thdxr

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

thdxr avatar Jun 19 '25 13:06 thdxr

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 avatar Jun 24 '25 06:06 mrloop

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 avatar Aug 15 '25 07:08 morgvanny

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

mrloop avatar Aug 17 '25 08:08 mrloop

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

adonh avatar Oct 05 '25 20:10 adonh

hm ill take a look

rekram1-node avatar Oct 06 '25 04:10 rekram1-node

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 avatar Nov 04 '25 22:11 synappsysai