volta icon indicating copy to clipboard operation
volta copied to clipboard

Calling `node` shouldn't add `yarn` to the PATH (calling `yarn` should)

Open arcanis opened this issue 6 months ago • 2 comments

Generally speaking, only tools that matter to the current process should be injected to the PATH. For example, running node ... should only add .volta/tools/image/node/22.13.1/bin to the PATH, not .volta/tools/image/yarn/1.22.19/bin. This last path should only be added to the PATH once the yarn shim is actually called.

The reason for that is that until the Yarn shim is called, Volta doesn't know whether it would ever be called. For example on my system only Node is managed by Volta on some projects, with the global yarn binary coming from another source, let's say /path/to/my/yarn. Unfortunately when calling execFile from within Node the Volta Yarn is unexpectedly called because Volta force-injected the shim.

As a workaround for this issue users can remove the yarn field from the ~/.volta/tools/user/platform.json file - this will prevent Volta from finding a path for Yarn, and thus to add it into the PATH.

arcanis avatar Jun 24 '25 21:06 arcanis

No one's maintaining it, the project should be shut down.

ZJRui avatar Jun 28 '25 12:06 ZJRui

I was testing this with Claude Code, which is written in Node.js, and the workaround doesn't seem to work.

If Volta is managing Node, Volta is still injecting its Yarn binary in the PATH even though no Yarn pin is set on the project or globally (~/.volta/tools/user/platform.json). Maybe there is an additional injection going through runtime?

Edit: found what was happened. When you run npm install -g <package> while Volta is managing npm, Volta creates a project config (i.e. ~/.volta/tools/user/packages/@anthropic-ai/claude-code.json) and pins the current Yarn version to it. The Yarn pint in those files also need to be removed.

ruimartin avatar Oct 14 '25 12:10 ruimartin