Skip to content

[rush] Allow subspaces to opt out of the PNPM global virtual store - #6154

Draft
Jérémy Dieuze (QuanticPotatoes) wants to merge 5 commits into
microsoft:mainfrom
QuanticPotatoes:d-11160-gvs-subspace-optout
Draft

Jérémy Dieuze (QuanticPotatoes) wants to merge 5 commits into
microsoft:mainfrom
QuanticPotatoes:d-11160-gvs-subspace-optout

Conversation

@QuanticPotatoes

@QuanticPotatoes Jérémy Dieuze (QuanticPotatoes) commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #6005. This branch contains #6005's commits unchanged; only the last commit (feat: allow subspaces to opt out of the PNPM global virtual store) is new here. I'll rebase once #6005 merges.

Summary

Adds an optional per-subspace opt-out from the PNPM global virtual store introduced in #6005:

// common/config/subspaces/<name>/pnpm-config.json
{
  "globalVirtualStore": false
}

When RUSH_PNPM_ENABLE_GLOBAL_VIRTUAL_STORE is enabled, every subspace uses the global virtual store unless its pnpm-config.json sets "globalVirtualStore": false.

Motivation

Some tooling cannot follow dependencies that live outside the subspace's temp folder. Our case: React Native's Metro bundler restricts watchFolders to the subspace's common/temp/<subspace>/node_modules. With the global virtual store, packages resolve to <store>/v11/links/..., outside every watched folder, and expo start fails with Failed to get the SHA-1. We want the global virtual store for the rest of the repo and plain installs for that one subspace.

Details

  • pnpm-config.schema.json / PnpmOptionsConfiguration: new optional globalVirtualStore boolean.
  • isPnpmGlobalVirtualStoreEnabled(subspace) (new logic/pnpm/PnpmGlobalVirtualStore.ts) is the single check, used by WorkspaceInstallManager (writing enableGlobalVirtualStore in pnpm-workspace.yaml) and getCommonTempFlag (so toggling it invalidates the last-install flag).
  • Fix: PnpmWorkspaceFile reloads an existing pnpm-workspace.yaml, so enableGlobalVirtualStore: true from a previous install was kept after opting out (or after unsetting the environment variable). The install now clears it when the global virtual store does not apply.

How it was tested

  • New WorkspaceInstallManager test: a subspace with "globalVirtualStore": false gets no enableGlobalVirtualStore in pnpm-workspace.yaml and no pnpmGlobalVirtualStore in the last-install flag; the existing test asserts both are set without the opt-out.
  • rush-lib tests for WorkspaceInstallManager, LastInstallFlag, BaseInstallManager, PnpmOptionsConfiguration and PnpmWorkspaceFile pass.

When RUSH_PNPM_ENABLE_GLOBAL_VIRTUAL_STORE=1, workspace installs set
enableGlobalVirtualStore in the generated pnpm-workspace.yaml so package
instances live in the shared PNPM store instead of each worktree's
node_modules/.pnpm.

Follow-up to microsoft#5830, rebased onto current main.

Co-authored-by: chenzhelong.sirius <EscapeB@users.noreply.github.com>
microsoft#5994 exported this regexp for TrimRushEnvironmentVariablesPlugin.
The GVS follow-up accidentally dropped it and inlined /^RUSH_/i.
@QuanticPotatoes
Jérémy Dieuze (QuanticPotatoes) force-pushed the d-11160-gvs-subspace-optout branch 3 times, most recently from 1d76bce to dc260df Compare October 19, 2026 18:32

This branch has not been deployed

No deployments
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