[rush] Add PNPM global virtual store support for rush install#5830
Open
EscapeB wants to merge 1 commit into
Open
[rush] Add PNPM global virtual store support for rush install#5830EscapeB wants to merge 1 commit into
EscapeB wants to merge 1 commit into
Conversation
96b4d3e to
5f2c85a
Compare
5f2c85a to
7a0be79
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Rush support for PNPM’s global virtual store for workspace installs.
This is especially useful for AI-assisted development workflows, where agents often create and delete multiple Git worktrees for the same monorepo in parallel. Without this, each worktree may recreate a large PNPM virtual store under
common/temp/node_modules/.pnpm, which makes worktree setup and cleanup expensive.When enabled, Rush writes
enableGlobalVirtualStore: trueto the generatedpnpm-workspace.yaml. PNPM then places package instance folders under the shared PNPM store instead of recreating them inside every worktree.The option defaults to
false, so existing repositories keep their current behavior unless they explicitly opt in.Details
A new
enableGlobalVirtualStoreoption is added topnpm-config.json.When enabled, Rush validates that:
10.12.1or newer."pnpmStore": "global"orRUSH_PNPM_STORE_PATH.RUSH_PNPM_STORE_PATH, if used, points outside the Rush repo.usePnpmSyncForInjectedDependenciesis not enabled, because pnpm-sync currently assumes the virtual store lives undernode_modules/.pnpm.With PNPM 10.12.1,
common/temp/node_modules/.pnpmmay still exist, but it only contains lightweight metadata such aslock.yamlandnode_modules. Package instance folders are stored under the shared PNPM store.This PR also avoids acquiring the global package manager install lock when the requested package manager is already installed and no matching install lock file exists. If a lock file exists, Rush still acquires the lock to preserve stale/dirty recovery behavior.
Testing
Ran the Rush lib test suite:
node common/scripts/install-run-rush.js test --to @microsoft/rush-lib --verboseAdded tests for config parsing, workspace file generation, validation errors, and package manager lock behavior.
Added a PNPM global virtual store integration test that creates a temporary Rush repo, enables the feature, runs:
The test verifies the generated workspace file, shared PNPM store usage, dependency links, and built output execution.
Also ran:
Result: npm, PNPM global virtual store, and yarn integration tests all passed.
Question
build-tests/rush-package-manager-integration-testpreviously only covered npm and yarn, and its package description referred to “non-pnpm package managers.” I added the PNPM case there because this feature needs real install-structure validation. Please confirm whether this is the right place for that coverage.