Repository navigation
[rush] With pnpm 12, rush update does not update pnpm-lock.yaml after pnpm changes a peer variant #6117
Description
Summary
We tried to move our Rush monorepo from pnpm 11 to pnpm 12. We changed only pnpmVersion in rush.json and ran rush update. A type check then failed because a package linked the wrong graphql version.
pnpm 12 picked a different peer variant and wrote it to common/temp/pnpm-lock.yaml. Rush did not copy that file to common/config/rush/pnpm-lock.yaml. The committed lockfile now records one version, and node_modules links another. rush install in a new clone links the same wrong version.
Repro steps
Repository: https://github.com/brunojppb/rush-pnpm-12-lockfile-issue
- Use Node 24.
- Clone the repository.
- Run
./repro.sh.
The script needs no global rush. It runs common/scripts/install-run-rush.js and does these steps:
appdepends ongraphql@17.0.0-alpha.7. The script runsrush updatewith pnpm 11.24.0.- The script removes
graphqlfromapp. It runsrush updatewith pnpm 11.24.0 again. - The script sets
pnpmVersionto 12.10.1. It runsrush update. - The script runs
rush purge, thenrush install.
app also depends on @graphql-typed-document-node/core@3.2.0, which has a peer dependency on graphql.
Expected result: After step 3, common/config/rush/pnpm-lock.yaml records graphql@16.13.1 for that peer. This is the version in common/temp/pnpm-lock.yaml and node_modules. After step 4, node_modules links the version that the committed lockfile records.
Actual result: rush update reports success, but the committed lockfile does not change:
== 3. Set pnpm to 12.10.1, then run rush update
temp lockfile: graphql@16.13.1
committed lockfile: graphql@17.0.0-alpha.7
node_modules: graphql@16.13.1
committed lockfile changed: no
== 4. Run rush purge, then rush install with pnpm 12.10.1
committed lockfile: graphql@17.0.0-alpha.7
node_modules: graphql@16.13.1
== Result
BUG: the committed lockfile records graphql@17.0.0-alpha.7, but node_modules links graphql@16.13.1.
Details
After step 2, the peer variant is graphql@17.0.0-alpha.7. This version does not satisfy the peer range ^17.0.0. pnpm 11 keeps the old peer variant. pnpm 12 resolves the peer again and picks graphql@16.13.1. pnpm 12 writes this version to common/temp/pnpm-lock.yaml.
Rush copies common/temp/pnpm-lock.yaml to common/config/rush/pnpm-lock.yaml only when its own check finds the lockfile out of date. In this case, the package.json files did not change, so Rush skips the copy. BaseInstallManager.ts has this comment in the branch that skips the copy:
| // TODO: Validate whether the package manager updated it in a nontrivial way |
rush install has a related problem. By default, it gives pnpm the --no-prefer-frozen-lockfile option. pnpm 12 then resolves the peers again and does not follow the committed lockfile.
Workarounds.
rush update --recheckcopies the temp lockfile to the committed lockfile."usePnpmFrozenLockfileForRushInstall": trueincommon/config/rush/experiments.jsonmakesrush installgive pnpm--frozen-lockfile. pnpm then follows the committed lockfile. This setting does not changerush update.
Potential fix
- After
rush updateruns pnpm, Rush could compare the temp lockfile with the committed lockfile. If the two files differ, Rush could copy the temp lockfile. - For
rush install, Rush could use--frozen-lockfilewith pnpm 12. Another option: Rush could fail when pnpm changes the temp lockfile duringrush install.
Standard questions
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
None. The repro runs common/scripts/install-run-rush.js. |
rushVersion from rush.json? |
5.181.0 |
pnpmVersion, npmVersion, or yarnVersion from rush.json? |
pnpm@12.10.1 (the repro starts with pnpm@11.24.0) |
(if pnpm) useWorkspaces from pnpm-config.json? |
true |
| Operating system? | Mac (macOS 26.6.2) |
| Would you consider contributing a PR? | TODO |
Node.js version (node -v)? |
24.21.0 |
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNeeds triage
Activity