Skip to content

[rush] Fix cross-subspace workspace:* dependencies failing under pnpm 11 (globalPnpmfile via pnpm-workspace.yaml) - #5913

Merged
Bharat Middha (bmiddha) merged 2 commits into
microsoft:mainfrom
QuanticPotatoes:fix/pnpm11-subspace-global-pnpmfile
Aug 6, 2026
Merged

[rush] Fix cross-subspace workspace:* dependencies failing under pnpm 11 (globalPnpmfile via pnpm-workspace.yaml)#5913
Bharat Middha (bmiddha) merged 2 commits into
microsoft:mainfrom
QuanticPotatoes:fix/pnpm11-subspace-global-pnpmfile

Conversation

@QuanticPotatoes

Copy link
Copy Markdown
Contributor

Summary

Fixes #5912.

With subspaces enabled, Rush generates a "global pnpmfile" (global-pnpmfile.cjs) that rewrites cross-subspace workspace:* dependency specifiers to link: specifiers. It is wired up via a global-pnpmfile= line in the generated .npmrc — but pnpm 11 only reads auth/registry settings from .npmrc, so the hook never loads and installation fails on the first subspace that carries a cross-subspace dependency:

ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In ../../../apps/api: "@my/tooling-package@workspace:*" is in the dependencies but no package named "@my/tooling-package" is present in the workspace

This is the counterpart of #5838 for the pnpmfile wiring: for pnpm 11+, the path is now emitted via the globalPnpmfile setting of the generated pnpm-workspace.yaml (which pnpm 11 still supports — and unlike the pnpmfile setting, it does not disable the default .pnpmfile.cjs loading, so the per-subspace user pnpmfile shim keeps working). Behavior for pnpm 10 and earlier is unchanged: the .npmrc line is still written (pnpm 11 ignores it).

Details

  • PnpmWorkspaceFile: new globalPnpmfile field (serialize + tryLoadAsync).
  • InstallHelpers.resolvePnpmSettings: when isPnpm11 && subspacesFeatureEnabled, sets workspaceFile.globalPnpmfile to <subspace temp folder>/global-pnpmfile.cjs — same relocation pattern as the [rush] Relocate pnpm settings to pnpm-workspace.yaml for pnpm 11 #5838 settings.
  • BaseInstallManager: comment documenting that the .npmrc line only reaches pnpm ≤ 10.

How it was tested

  • rush-lib full suite: 724 passed / 0 failed. New tests: PnpmWorkspaceFile serialize + round-trip for globalPnpmfile; InstallHelpers emits the path for pnpm 11 + subspaces (new pnpmConfigPnpm11Subspaces fixture), and does not emit it for pnpm 11 without subspaces nor for pnpm < 11 with subspaces.
  • End-to-end against a real subspaces monorepo (8 subspaces, cross-subspace workspace:* dev-tooling deps) on pnpm 11.17.0: without the setting, rush update fails with ERR_PNPM_WORKSPACE_PKG_NOT_FOUND; with globalPnpmfile appended to the generated pnpm-workspace.yaml (what this PR automates), the same install resolves cleanly.

🤖 Generated with Claude Code

@QuanticPotatoes

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Abby"

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes pnpm 11 cross-subspace workspace:* resolution by configuring Rush’s global pnpmfile through pnpm-workspace.yaml.

Changes:

  • Adds globalPnpmfile serialization and loading support.
  • Emits the pnpmfile path for pnpm 11 subspace installs.
  • Adds fixtures, tests, snapshots, and release notes.
Show a summary per file
File Description
libraries/rush-lib/src/logic/test/pnpmConfigPnpm11Subspaces/rush.json Adds pnpm 11 test fixture.
libraries/rush-lib/src/logic/test/pnpmConfigPnpm11Subspaces/common/config/subspaces/default/pnpm-config.json Adds default subspace configuration.
libraries/rush-lib/src/logic/test/pnpmConfigPnpm11Subspaces/common/config/rush/subspaces.json Enables subspaces in the fixture.
libraries/rush-lib/src/logic/test/pnpmConfigPnpm11Subspaces/common/config/rush/pnpm-config.json Enables workspace mode.
libraries/rush-lib/src/logic/test/InstallHelpers.test.ts Tests version and subspace gating.
libraries/rush-lib/src/logic/test/__snapshots__/InstallHelpers.test.ts.snap Updates terminal snapshots.
libraries/rush-lib/src/logic/pnpm/test/PnpmWorkspaceFile.test.ts Tests serialization and loading.
libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmWorkspaceFile.test.ts.snap Captures generated YAML.
libraries/rush-lib/src/logic/pnpm/PnpmWorkspaceFile.ts Supports the globalPnpmfile setting.
libraries/rush-lib/src/logic/installManager/InstallHelpers.ts Configures the global pnpmfile for pnpm 11 subspaces.
libraries/rush-lib/src/logic/base/BaseInstallManager.ts Documents legacy .npmrc behavior.
common/changes/@microsoft/rush/fix-pnpm11-subspace-global-pnpmfile_2026-08-04-08-30-00.json Records the user-facing fix.

Review details

  • Files reviewed: 12/12 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@bmiddha
Bharat Middha (bmiddha) enabled auto-merge (squash) August 6, 2026 03:23
@bmiddha
Bharat Middha (bmiddha) enabled auto-merge (squash) August 6, 2026 03:23
@bmiddha
Bharat Middha (bmiddha) merged commit d111fd3 into microsoft:main Aug 6, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[rush] Subspaces + pnpm 11: cross-subspace workspace:* deps fail — global-pnpmfile is wired via .npmrc, which pnpm 11 ignores

3 participants