Repository navigation
[rush] Fix rush publish for projects using pnpm catalog: dependencies - #6132
Merged
Bharat Middha (bmiddha) merged 4 commits intoOct 18, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Install-time registry and credential settings can override .npmrc-publish, causing incorrect registry selection or authentication failures.
1 open finding
What changed in this PR
This PR enables Rush’s publishing workflow to resolve pnpm catalog dependencies using each project’s generated subspace workspace.
Changes:
- Configure the workspace directory for pnpm publish and pack when workspaces are enabled.
- Add a Rush change entry describing the fix.
| File | Description |
|---|---|
| libraries/rush-lib/src/cli/actions/PublishAction.ts | Pass the project’s subspace workspace to pnpm publish and pack. |
| common/changes/@microsoft/rush/fix-rush-publish-pnpm-catalogs_2026-10-14-04-30.json | Record the catalog publishing fix. |
🧠 Review effort: Max
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
David Michon (dmichon-msft)
approved these changes
Oct 14, 2026
Bharat Middha (bmiddha)
enabled auto-merge (squash)
October 15, 2026 01:18
Set NPM_CONFIG_WORKSPACE_DIR to the project's subspace temp folder for pnpm publish/pack so pnpm can find the generated pnpm-workspace.yaml catalogs, matching rush-pnpm. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pointing NPM_CONFIG_WORKSPACE_DIR at the subspace temp folder caused pnpm publish to copy the install-time .npmrc into its temp publish folder, overriding common/config/rush/.npmrc-publish. Generate common/temp/publish-workspaces/<subspace>/pnpm-workspace.yaml containing only the catalogs instead, and only when catalogs are configured. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Build publish workspace paths with template strings. - Allow PnpmWorkspaceFile settings to be passed to the constructor and use it for the catalog-only publish workspace. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bharat Middha (bmiddha)
force-pushed
the
bmiddha-fix-rush-publish-pnpm-catalogs
branch
from
October 15, 2026 19:11
c6dedf0 to
8f36e35
Compare
Bharat Middha (bmiddha)
deleted the
bmiddha-fix-rush-publish-pnpm-catalogs
branch
October 18, 2026 00:00
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 publish(--publishor--pack) failed for any published project that used a pnpmcatalog:/catalog:defaultspecifier fromglobalCatalogs:rush install,rush update, andrush-pnpm pack/publishall worked. This PR pointspnpm publish/pnpm packat an isolated, catalog-only pnpm workspace so thatcatalog:specifiers are rewritten correctly.Related: #5623, #5467, #5627
Details
PublishActionrunspnpm publish/pnpm packfrom the project's publish folder. pnpm rewritescatalog:specifiers usingpnpm-workspace.yaml, which it finds by searching upward from the working directory. Rush generates that file incommon/temp(or the subspace temp folder), and that folder is not a parent of the project, so pnpm found no catalogs.rush-pnpmavoids this by settingNPM_CONFIG_WORKSPACE_DIRto the subspace temp folder.rush publishcan't reuse that folder: pnpm'spublishcopies<workspaceDir>/.npmrcinto its temporary publish folder whenever the project has no.npmrc, then runsnpm publishthere (copyNpmrcin pnpm 10). The install-time.npmrcwould then become project-level npm config and overridecommon/config/rush/.npmrc-publish, which Rush supplies only at the user level through thepublish-homeHOME redirect.Instead, for each subspace that has catalogs configured, Rush now generates
common/temp/publish-workspaces/<subspace>/pnpm-workspace.yaml. That file contains onlycatalogs, and the folder has no.npmrc. Rush then setsNPM_CONFIG_WORKSPACE_DIRto that folder for#npmPublishAsyncand#npmPackAsync. The folder is created once per subspace per run.subspace.getPnpmOptions() ?? rushConfiguration.pnpmOptions)..npmrc-publish,--registry, and--npm-auth-tokenbehave as they did.isPnpm && useWorkspacesandglobalCatalogsis non-empty. Repos without catalogs, and npm and Yarn repos, see no change.rush publishalready rewritesworkspace:ranges itself, so the generated workspace only needscatalogsand does not list any packages.How it was tested
Build:
node common/scripts/install-run-rush.js build --to @microsoft/rushpassed, with lint included.I tested manually with pnpm 10.26.0 and
useWorkspaces: trueon two scratch repos:lib-adepends on"is-number": "catalog:", andglobalCatalogs.defaultpins7.0.0.lib-ais in subspacesa(catalog7.0.0), andlib-bis in subspacesb(catalog6.0.0).apps/rush/lib-commonjs/start-dev.js)rush publish --include-all --pack(single)ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC"is-number": "7.0.0"rush publish --include-all --pack(subspaces)lib-a→7.0.0,lib-b→6.0.0rush publish --include-all --publish(single)"is-number": "7.0.0"rush publish --include-all --publish(subspaces)lib-bpublished with"is-number": "6.0.0".npmrc-publishprecedence. I set up two Verdaccio instances. The install.npmrcpoints at127.0.0.1:4874, which rejects publishes.common/config/rush/.npmrc-publishpoints at127.0.0.1:4873with an auth token. I passed no--registryor--npm-auth-token.NPM_CONFIG_WORKSPACE_DIR=common/temp), publish fails withENEEDAUTH ... http://127.0.0.1:4874/. The copied install.npmrcoverrides.npmrc-publish.127.0.0.1:4873with the catalog version resolved.All manual testing was done on the final commit. I did not add unit tests because
PublishActionhas no existing test harness.