Skip to content

[rush] Add PNPM global virtual store support for rush install#5830

Open
EscapeB wants to merge 1 commit into
microsoft:mainfrom
EscapeB:feat/support_pnpm_global_virtual_store
Open

[rush] Add PNPM global virtual store support for rush install#5830
EscapeB wants to merge 1 commit into
microsoft:mainfrom
EscapeB:feat/support_pnpm_global_virtual_store

Conversation

@EscapeB

@EscapeB EscapeB commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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: true to the generated pnpm-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 enableGlobalVirtualStore option is added to pnpm-config.json.

When enabled, Rush validates that:

  • PNPM is version 10.12.1 or newer.
  • The PNPM store is shared via "pnpmStore": "global" or RUSH_PNPM_STORE_PATH.
  • RUSH_PNPM_STORE_PATH, if used, points outside the Rush repo.
  • usePnpmSyncForInjectedDependencies is not enabled, because pnpm-sync currently assumes the virtual store lives under node_modules/.pnpm.

With PNPM 10.12.1, common/temp/node_modules/.pnpm may still exist, but it only contains lightweight metadata such as lock.yaml and node_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 --verbose

Added 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:

rush update
rush install
rush build

The test verifies the generated workspace file, shared PNPM store usage, dependency links, and built output execution.

Also ran:

cd build-tests/rush-package-manager-integration-test
npm run test

Result: npm, PNPM global virtual store, and yarn integration tests all passed.

Question

build-tests/rush-package-manager-integration-test previously 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.

@EscapeB EscapeB force-pushed the feat/support_pnpm_global_virtual_store branch from 5f2c85a to 7a0be79 Compare June 11, 2026 13:13
@EscapeB

EscapeB commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @octogonz @iclanton, could you please take some time to review this PR and see if there are any issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant