volta icon indicating copy to clipboard operation
volta copied to clipboard

Project yarn version from Claude Code

Open mweidner037 opened this issue 8 months ago • 2 comments

I've installed Claude Code using npm install -g @anthropic-ai/claude-code. This works (I can start it with claude), but within Claude Code, Volta appears to change the PATH.

Specifically, if I ask Claude Code to echo $PATH, its value starts with

/Users/me/.volta/tools/image/yarn/4.9.1/bin:/Users/me/.volta/tools/image/node/22.15.0/bin:...

followed by the result that I get when running echo $PATH myself in zsh. I'm guessing the new entries result from the fact that the claude command is itself managed by Volta, due to npm -g.

My issue with this is, whenever claude runs yarn in its internal shell, it gets the global yarn & node versions - even if its working directory is a project that overrides the local yarn version (via package.json "volta" key). Indeed, because yarn 4.9.1 (global version) appears first in claude's PATH, it takes priority over the /Users/me/.volta/bin/yarn shim appearing later in the PATH (which is what I get when running yarn myself in zsh).

Do you think the PATH change is actually due to volta, or a quirk of claude code? If the former, is there a way to override it and let Claude Code use my project's version of yarn?

Possibly related: https://github.com/volta-cli/volta/issues/492

mweidner037 avatar Apr 29 '25 23:04 mweidner037

Curiously, the behavior persists even after changing the system version of yarn to match my project (1.22.19) and restarting my terminal: claude code still gets yarn 4.9.1 (the old system version). I am able to get my desired version by reinstalling volta completely and installing 1.22.19 as my first & only yarn version.

mweidner037 avatar Apr 30 '25 17:04 mweidner037

Facing this now with PNPM, since upgrading to ClaudeCode to 1.103.0, so seems like they have switch the package manager

secustor avatar Sep 04 '25 12:09 secustor