Main icon indicating copy to clipboard operation
Main copied to clipboard

pnpm: persist global data and add to path

Open jack-mil opened this issue 8 months ago • 5 comments

Following off of the similar python and rustup manifests, I have updated pnpm to make use of the $PNPM_HOME env variable in order to install global packages or cli utilities into a scoop-managed and persisted directory (instead of the default on windows: ~/AppData/Local/pnpm/global

An alternative approach would be to:

a) Leave the pnpm default global directory as is, and simply add ~/AppData/Local/pnpm/global to PATH when installing the manifest. This would also fix issues like #6713. But the application data would not be contained within the ~/scoop folder (generally prefered).

b) Instruct users to run pnpm setup after installation, which will - create a home directory for the pnpm CLI (~/AppData/Local/pnpm/global) - adds the pnpm home directory to the PATH environment variable - copies the pnpm executable to the pnpm home directory In this case however, scoop will no longer manage pnpm at all, and it will be no different than installing manually (without scoop).

Note: $PNPM_HOME cannot be set to "$persist_dir\pnpm_data" because it seems that pnpm checks at runtime if the exact directory $PNPM_HOME is in $PATH, and doesn't follow symlinks.

Fixes: #6713

  • [x] Use conventional PR title: <manifest-name[@version]|chore>: <general summary of the pull request>
  • [x] I have read the Contributing Guide

jack-mil avatar Apr 24 '25 01:04 jack-mil

All changes look good.

Wait for review from human collaborators.

pnpm

  • [x] Description
  • [x] License
  • [x] Hashes
  • [x] Checkver
  • [x] Autoupdate

github-actions[bot] avatar Apr 24 '25 01:04 github-actions[bot]

I realize that this is a pretty major breaking change to those using this manifest already. Migration or at the very least a warning on updating is probably required. I would need advice on what is the canonical way to do that; if this change is even deemed necessary in the first place.

jack-mil avatar Apr 24 '25 01:04 jack-mil

See https://github.com/ScoopInstaller/Main/pull/6462#issuecomment-2812476661

Lutra-Fs avatar May 28 '25 04:05 Lutra-Fs

I have finally gotten to this. I am not a pnpm user, so I don't know if this change is even wanted across the board. This manifest will have similar behavior to other scoop apps now, and at-least one issue has a desire to manage the global installation environment.

jack-mil avatar Jun 17 '25 20:06 jack-mil

For #6713, We should provide script similar pnpm setup, i.e.:

  1. Set $env:PNPM_HOME to $env:LOCALAPPDATA\pnpm
  2. Add $env:PNPM_HOME to $env:PATH

cacheDir and stateDir can set by pnpm config(config file), but the location of config file of pnpm(Windows) is fixed $env:LOCALAPPDATA\pnpm\config\rc.

  • https://pnpm.io/cli/config
  • https://pnpm.io/settings

pnpm self-update will install its newer version to $env:PNPM_HOME, when current version is standalone executable(Scoop provided), instead, use a NPM package manager will not caused this issue.


Personally, I prefer to install pnpm or other global packages via bun add -g <package>. npm add -g pnpm are recommend by pnpm official document. I understand that users need persistence to migrate/backup their data files quickly.

HUMORCE avatar Jul 10 '25 17:07 HUMORCE