opencode
opencode copied to clipboard
Unable to run opencode when node/npm is managed by Volta
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 😄
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
going to close this for now if someone has insight on how to fix this please leave a comment
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
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:
- Installs to a temporary directory first (e.g.,
~/.volta/tmp/image/packages/.tmpwVekLa/) - Runs postinstall scripts (symlink created with absolute path to temp dir)
- Moves the package to its final location (
~/.volta/tools/image/packages/opencode-ai/) - 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.
Thanks @morgvanny fix working for me :tada: https://github.com/sst/opencode/pull/2014
plx fix in the default post-install script. TY!
hm ill take a look
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 %