[rush] Fix "rush-pnpm patch-commit" writing absolute paths into pnpm-config.json#5875
Merged
iclanton merged 1 commit intoJul 18, 2026
Merged
Conversation
ATKasem
requested review from
apostolisms,
bmiddha,
dmichon-msft,
iclanton,
jxanthony and
octogonz
as code owners
July 16, 2026 13:25
iclanton
reviewed
Jul 16, 2026
ATKasem
force-pushed
the
fix/rush-pnpm-patch-absolute-paths
branch
2 times, most recently
from
July 17, 2026 19:37
705af95 to
3a8b6d1
Compare
…config.json When running "pnpm patch-commit"/"patch-remove" with pnpm 9+, pnpm rewrites pre-existing patchedDependencies entries using absolute paths into common/temp. Rush then copied those into pnpm-config.json, leaking the local checkout location. Normalize absolute paths under the common/temp folder back to relative paths at the point they are recorded, inside PnpmOptionsConfiguration.updateGlobalPatchedDependencies. This is the single sink for both the pnpm 11+ (pnpm-workspace.yaml) and older (package.json) sources, so both are covered.
ATKasem
force-pushed
the
fix/rush-pnpm-patch-absolute-paths
branch
from
July 17, 2026 19:43
3a8b6d1 to
1193824
Compare
iclanton
reviewed
Jul 17, 2026
iclanton
approved these changes
Jul 18, 2026
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
Fixes #5348
When a repo already has entries in
globalPatchedDependenciesand another patch is added withrush-pnpm patch-commit, the pre-existing entries get rewritten inpnpm-config.jsonas absolute paths (e.g./home/user/repo/common/temp/patches/foo@1.0.0.patch), leaking the local checkout location into a committed config file.The cause is on the pnpm side: pnpm >= 9 rewrites the pre-existing
patchedDependenciesentries in the workspace package.json using absolute paths when runningpatch-commit/patch-remove(reproduced in isolation with pnpm 10.7.1 — the new entry is written relative, the old ones become absolute).rush-pnpmthen copied that map verbatim fromcommon/temp/<subspace>/package.jsonintopnpm-config.json.Details
RushPnpmCommandLineParsernow normalizes the map read back from the temp package.json before persisting: any value that is an absolute path under the subspace temp folder is converted back to a temp-relative POSIX path (patches/example@1.0.0.patch). Relative values and absolute paths outside the temp folder are left unchanged. The normalization happens before the deep-equal comparison, so entries that only differ by pnpm's absolutization no longer register as changes.How it was tested
RushPnpmCommandLineParser.test.ts(absolute-under-temp conversion, relative passthrough, absolute-outside-temp passthrough,undefinedpassthrough);heft testpasses 7/7 for the suite.rush build --to @microsoft/rush-lib(tsc + lint) passes.RushPluginCommandLineParameters.test.tsreproduce identically on an unmodifiedmaincheckout in this environment, so they are unrelated to this change.