Can't upgrade pnpm due to ERR_PNPM_UNEXPECTED_VIRTUAL_STORE
Verify latest release
- [X] I verified that the issue exists in the latest pnpm release
pnpm version
9.0.3
Which area(s) of pnpm are affected? (leave empty if unsure)
CLI, Store
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
Run pnpm add -g pnpm .
Describe the Bug
Running pnpm add told me to upgrade pnpm (I've lost the specific message by now).
Running pnpm add -g pnpm as directed yields:
ERR_PNPM_UNEXPECTED_VIRTUAL_STORE Unexpected virtual store location
The dependencies at "/var/home/virgil/.local/share/pnpm/global/5/node_modules" are currently symlinked from the virtual store directory at "/var/home/virgil/.local/share/pnpm/global/5/.pnpm".
pnpm now wants to use the virtual store at "/home/virgil/.local/share/pnpm/global/5/.pnpm" to link dependencies from the store.
If you want to use the new virtual store location, reinstall your dependencies with "pnpm install".
You may change the virtual store location by changing the value of the virtual-store-dir config.
Running pnpm install as directed does not affect the issue. I can't tell from the information provided how to resolve the issue.
The issue may be related to /home being a symlink on my system.
Expected Behavior
The suggested upgrade command should have succeeded.
Which Node.js version are you using?
20.12.0
Which operating systems have you used?
- [ ] macOS
- [ ] Windows
- [X] Linux
If your OS is a Linux based, which one it is? (Include the version if relevant)
Fedora
Running pnpm config set virtual-store-dir with either the old or new store directory does not resolve the issue so the last line of the message seems unhelpful.
I have the same issue on a second system also running Fedora Silverblue with a symlinked home directory.
My workaround so far is to use npm (instead of pnpm) for global install...
https://github.com/pnpm/pnpm/issues/5551#issuecomment-1292718569
this worked for me
The recommended way to update pnpm is now pnpm self-update. This error will never happen with pnpm self-update.