[lockfile-explorer] Change error to warning for outdated pnpm-lock.yaml format#5645
[lockfile-explorer] Change error to warning for outdated pnpm-lock.yaml format#5645EasonLin0716 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
iclanton
left a comment
There was a problem hiding this comment.
You need a changelog entry. Run rush change
| throw new Error('Expecting leading "/" in path: ' + JSON.stringify(rawEntryId)); | ||
| if (!hasWarnedAboutOutdatedFormat) { | ||
| console.warn( | ||
| 'Your pnpm-lock.yaml contains outdated version formats. Please run "rush update --full" to fix this issue.' |
There was a problem hiding this comment.
Does this only happen in a case when rush update --full will fix it?
There was a problem hiding this comment.
changelog is added. Please take a look, thank you.
Does this only happen in a case when rush update --full will fix it?
This case happens when users haven't run rush update --full after migrating their pnpm version, especially from v8 to v9. Users can either run rush update --full or remove the pnpm-lock.yaml and run rush install again to fix it.
|
@EasonLin0716 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Fixed #5400
Summary
In pnpm v9+, the version field format dropped the
registry.npmjs.org/prefix. Teams using Rush.js may have members running different versions of pnpm, but they may not necessarily runrush update --fullor rebuildpnpm-lock.yamlto normalize the version format — especially in large projects with many packages, where doing so could cause unexpected errors due to some packages not strictly following SemVer.In #5377, support for pnpm v10 was added, but this also caused teams that haven't cleaned up their
pnpm-lock.yamlto no longer be able to use it. My approach is to emit a warning instead of throwing an error as a workaround, so that teams encountering this issue aren't left blocked without knowing how to resolve it.console.erroratapps/lockfile-explorer/src/graph/lfxGraphLoader.ts:614might still be invoked, but I think it is better than throwing an error and ending the process.Details
Previous behavior: The code would throw an error when
encountering entries without a leading "/" in pre-v9.0 lockfiles.
New behavior:
hasWarnedAboutOutdatedFormatto trackif the warning has been shown
once: "Your pnpm-lock.yaml contains outdated version formats. Please
run 'rush update --full' to fix this issue."
the tool to continue working
Backwards compatibility: This change improves backwards
compatibility by making the tool more tolerant of legacy lockfile
formats.
Performance impact: Minimal - only adds a single boolean check
per lockfile entry.
How it was tested
Manually tested by running lockfile-explorer against projects with
outdated pnpm-lock.yaml formats and verified:
exist
Impacted documentation
No documentation updates required.