If pnpm is installed, to run pnpm up -g as the user (not as root).
What actually happened?
If there is no /usr/local/lib/node_modules (which, if you use pnpm instead of npm to install global packages, doesn't exist): npm: SKIPPED: NPM root at /usr/local/lib/node_modules doesn't exist
If that directory is arbitrarily created: npm: SKIPPED: NPM root is owned by another user which is not the current user. Set use_sudo = true under the NPM section in your configuration to run NPM as sudo
If use_sudo is set to true, pnpm cannot update as it operates in the user's home directory
This means that there is no way for topgrade update pnpm's global packages.
Per the logs (attached in details), even after it detects that pnpm exists, it runs npm root -g.
It should instead run pnpm root -g as that correctly returns /home/$USER/.local/share/pnpm/global/5/node_modules.
Proposed Fix
Topgrade could possibly keep track of a variable such as node-package-manager, set it to npm by default, and if pnpm is detected, set it to pnpm instead. Any commands run, such as up or root would be run based on the package-manager. This might also simplify the logic in checking pnpm, as once the node-package-manager variable is set, all other commands can run agnostic to which package manager is actually being used (versus tracking pnpm as a seperate option, as seems to be done at a cursory glance at the code). This method would also allow easier support to other npm-compatible package managers that become popular in the future.
Additional Details
Which operating system or Linux distribution are you using?
Fedora Linux 37
What did you expect to happen?
If pnpm is installed, to run
pnpm up -g
as the user (not as root).What actually happened?
npm: SKIPPED: NPM root at /usr/local/lib/node_modules doesn't exist
npm: SKIPPED: NPM root is owned by another user which is not the current user. Set use_sudo = true under the NPM section in your configuration to run NPM as sudo
use_sudo
is set to true, pnpm cannot update as it operates in the user's home directoryThis means that there is no way for topgrade update pnpm's global packages.
Per the logs (attached in details), even after it detects that
pnpm
exists, it runsnpm root -g
. It should instead runpnpm root -g
as that correctly returns/home/$USER/.local/share/pnpm/global/5/node_modules
.Proposed Fix
Topgrade could possibly keep track of a variable such as
node-package-manager
, set it tonpm
by default, and if pnpm is detected, set it topnpm
instead. Any commands run, such asup
orroot
would be run based on thepackage-manager
. This might also simplify the logic in checking pnpm, as once thenode-package-manager
variable is set, all other commands can run agnostic to which package manager is actually being used (versus tracking pnpm as a seperate option, as seems to be done at a cursory glance at the code). This method would also allow easier support to other npm-compatible package managers that become popular in the future.Additional Details