Skip to content

[rush] Fix sync-back when dependencies move to devDependencies#5811

Merged
iclanton merged 3 commits into
microsoft:mainfrom
ericprestemon:fix/detect-dependencies-moved-to-dev-deps
Jun 7, 2026
Merged

[rush] Fix sync-back when dependencies move to devDependencies#5811
iclanton merged 3 commits into
microsoft:mainfrom
ericprestemon:fix/detect-dependencies-moved-to-dev-deps

Conversation

@ericprestemon
Copy link
Copy Markdown
Contributor

@ericprestemon ericprestemon commented May 29, 2026

Summary

When a project dependency is moved from dependencies to devDependencies, rush update would correctly update the temporary lockfile but fail to sync it back to common/config/rush/. This left the repository with a stale committed lockfile despite the install appearing to succeed.

Details

The root cause was an unconditional fall-through in isWorkspaceProjectModifiedAsync (the PNPM v8+ logic path). When checking a project's devDependencies, if a package was missing from the lockfile's devDependencies section, the code would automatically check the dependencies section instead.

While this fall-through is necessary to support dual-declarations (which PNPM collapses into the dependencies section of the lockfile), it was also masking the case where a package had been moved out of the regular dependencies section entirely.

The fix introduces a regularDependencyNames set for the project and gates the fall-through on membership in that set. This preserves support for dual-declared packages while correctly identifying a stale lockfile when a package has been moved to devDependencies.

How it was tested

  • Added a regression test in PnpmShrinkwrapFile.test.ts.
  • Created a new test fixture stale-dev-in-dependencies.yaml that simulates a lockfile where a moved dependency is still incorrectly listed in the dependencies section.
  • Verified that the new test fails without the fix and passes with it.
  • Ran the full rush-lib test suite to ensure no regressions in other lockfile sync scenarios.

'rush update' failed to sync back the corrected pnpm-lock.yaml when a dependency moved to devDependencies because
isWorkspaceProjectModifiedAsync would unconditionally fall through to the 'dependencies' section if a package was
missing from 'devDependencies'.

This fall-through is now gated on the new set regularDependencyNames to support legitimate dual-declarations while
correctly detecting when a dependency has been moved out of the 'dependencies' section.
ericprestemon and others added 2 commits June 6, 2026 17:07
…ync_2026-05-29-12-00.json

Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
…ync_2026-05-29-12-00.json

Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
@iclanton iclanton enabled auto-merge (squash) June 7, 2026 00:08
@iclanton iclanton merged commit 3134980 into microsoft:main Jun 7, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants