Repository navigation
[rush] Make version consistency checks aware of PNPM catalogs - #6140
Draft
Bharat Middha (bmiddha) wants to merge 1 commit into
Draft
Bharat Middha (bmiddha) wants to merge 1 commit into
Bharat Middha (bmiddha) wants to merge 1 commit into
Conversation
Bharat Middha (bmiddha)
force-pushed
the
bmiddha-catalog-aware-version-checks
branch
from
October 14, 2026 20:54
664d3de to
eff340a
Compare
Bharat Middha (bmiddha)
added this pull request to stack #6134
October 14, 2026 21:29
Compare PNPM catalog references by the version that they resolve to in the catalogs of the project's subspace, so "catalog:" no longer mismatches the same literal version or preferredVersions in "rush check", ensureConsistentVersions, and "rush version". Unresolvable references are reported as their own version. "rush check" annotates catalog versions and "rush check --json" adds an optional "catalogReferences" field. "--make-consistent" no longer rewrites other projects' catalog references to literal versions; it warns instead. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bharat Middha (bmiddha)
force-pushed
the
bmiddha-catalog-aware-version-checks
branch
from
October 15, 2026 01:47
eff340a to
f2519b0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rush's version consistency checks compared raw version specifiers, so a project using
"typescript": "catalog:"was reported as inconsistent with another project using"typescript": "~5.8.2", or with the same version inpreferredVersions. It was even reported as inconsistent with a project using"typescript": "catalog:default". WithensureConsistentVersions: true, this maderush install/rush update/rush check/rush versionfail as soon as a repo adopted PNPM catalogs.Version consistency checks now compare a catalog reference by the version that it resolves to in the catalogs of the project's subspace. This also changes
--make-consistent: it no longer rewrites other projects'catalog:references to literal versions.Details
Resolution (
VersionMismatchFinder)getMismatches()computes the subspace's effective catalogs once, withgetEffectivePnpmCatalogs(): the subspace'spnpm-config.json, elsecommon/config/rush/pnpm-config.json. These are exactly what install writes. EachVersionMismatchFinderProjectreceives them.#analyze()resolves each catalog spec withtryResolvePnpmCatalogReference()before grouping:catalog:andcatalog:defaultresolve to the same entry.catalog:react17resolve to their own entry.preferredVersions.catalog:/catalog:<name>) as their "version". So they surface as their own version instead of crashing or being silently dropped, andcatalog:vscatalog:defaultstill collapse together.allowedAlternativeVersionsmatches the resolved version exactly like a literal. For backward compatibility it also matches the raw catalog spec (e.g."catalog:react17").--variant. Every entry point already routes throughgetMismatches(), so they all pick this up:rush check(including--subspace/--variant/--json)ensureConsistentVersionsgate in install/updaterush versionrush add/rush upgrade-interactive --make-consistentReporting
rush checkannotates versions that come from a catalog, and any consumer whose raw spec differs from the printed version:rush check --json:versionreports the resolved version. That is what PNPM installs, and it groups naturally with literals andpreferredVersions.catalogReferences: [{ project, versionSpecifier }]field is added to a version entry only when some consumer used a catalog.--make-consistentguard (PackageJsonUpdater)#getUpdates()rewrote every other consumer to the literal version, including projects that reference the package throughcatalog:, which silently detached them from the catalog.updateProject()) is a catalog reference is skipped. If its resolved version differs, Rush prints a deduped warning:Not updating "<pkg>" in "<project>" because it uses the PNPM catalog reference "catalog:" (^7.5.4). Rush does not replace catalog references when making versions consistent; update the catalog in pnpm-config.json instead.rush add/rush upgrade-interactivestill overwrites the target project's owncatalog:spec. A later layer of this stack covers catalog-awarerush add/upgrade-interactive.Other
formatPnpmCatalogSpecifier()toPnpmCatalogReference.ts.ProjectChangeAnalyzernow usestryParsePnpmCatalogName()to detect catalog references. This trims the catalog name the way PNPM does, socatalog: toolsmaps totools.How it was tested
New unit tests:
VersionMismatchFinder.test.tscovers:catalog:vs the same literalcatalog:vscatalog:defaultcatalog:vs a different literalcatalog:vspreferredVersionsallowedAlternativeVersions(resolved and raw spec)print()andprintAsJson()outputgetMismatches()on therepoWithCatalogsandrepoWithSubspacesCommonCatalogsfixtures (default, fallback, and own-config subspaces)PackageJsonUpdater.test.ts(new):--make-consistentkeepscatalog:in other projects and warns once per project.PnpmCatalogReference.test.tscoversformatPnpmCatalogSpecifier().ProjectChangeAnalyzer.test.tscovers catalog name normalization.Commands run on the final commit (
664d3dea26):node <dev rush>/start-dev.js build --to @microsoft/rush-lib: passed, with no warnings.cd libraries/rush-lib && node_modules/.bin/heft test --test-path-pattern "VersionMismatchFinder|PnpmCatalogReference|ProjectChangeAnalyzer|PackageJsonUpdater": passed (all 90 tests).cd libraries/rush-lib && node_modules/.bin/heft test: 1976 passed and 1 failed (1979 total). The only failure is the known pre-existingTarExecutable › kills tar when its signal aborts while it runs, which is unrelated.VersionMismatchFinder.getMismatches()on this repo's ownrush.json, using the builtlib-commonjs: 0 mismatches in both thedefaultandbuild-tests-subspacesubspaces, so there is no regression for a repo without catalogs.Impacted documentation
catalogReferencesJSON field.ensureConsistentVersions/allowedAlternativeVersionsnow compare catalog references by their resolved version.