Skip to content

Add enableAutoDedupe option - #344

Open
latin-1 wants to merge 1 commit into
yarnpkg:mainfrom
latin-1:feat/enable-auto-dedupe
Open

latin-1 wants to merge 1 commit into
yarnpkg:mainfrom
latin-1:feat/enable-auto-dedupe

Conversation

@latin-1

@latin-1 latin-1 commented Sep 25, 2026 •

Copy link
Copy Markdown

Disclosure: This PR uses Codex.

Automatically deduplicate dependencies with the highest strategy during explicit installs, before linking and building. Preserve lazy installs, focused installs, and explicit dedupe patterns.

Fixes #343

@netlify

netlify Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

馃懛 Deploy request for yarn-v6 pending review.

Visit the deploys page to approve it

Name Link
馃敤 Latest commit a3cae15

@latin-1

latin-1 commented Sep 25, 2026

Copy link
Copy Markdown
Author

@arcanis pnpm skips autoDedupe during frozen installs, so CI installs the locked versions even if duplicates exist. This implementation runs deduplication during immutable installs and fails if it would change the lockfile, effectively enforcing dedupe --check. Should we match pnpm and skip deduplication, or enforce a deduplicated lockfile on CI?

@arcanis

arcanis commented Sep 25, 2026

Copy link
Copy Markdown
Member

I believe we should run the dedupe as usual. Immutable installs guarantee that your colleagues won't get spurious changes in the lockfiles their PRs after you merge your work, skipping dedupe would break that promise.

@latin-1

latin-1 commented Oct 2, 2026

Copy link
Copy Markdown
Author

Should we add --auto-dedupe and --no-auto-dedupe like pnpm? Since we don鈥檛 have --constraints and --no-constraints either, maybe it鈥檚 fine not to add them.

@latin-1
latin-1 force-pushed the feat/enable-auto-dedupe branch 3 times, most recently from 13d5d55 to 77a27c5 Compare October 6, 2026 21:53
Comment thread packages/zpm/src/commands/install.rs Outdated
// fast path so that a manually damaged project (say, a deleted
// package folder) heals when the user reaches for `yarn install`.
if !self.force
&& !project.config.settings.enable_auto_dedupe.value

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be an unfortunate limitation - I think if is_install_up_to_date returns true we should rather assume that auto-dedupe already ran, rather than always run the full install, no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design Codex originally suggested was to skip auto-dedupe in lazy mode. As a result, in that case, is_install_up_to_date doesn't necessarily mean that dedupe has already been performed.

I've updated the PR so that dedupe now runs normally in lazy mode as well. I'm not entirely sure which behavior is preferable, but given that pnpm appears to run dedupe during automatic installs too, I don't think this should be a major issue.

The only complication is that lazy installs with yarn dedupe need to be handled as a special case. It looks a little odd, but, well, there doesn't really seem to be a better way around it.

@latin-1
latin-1 force-pushed the feat/enable-auto-dedupe branch from 77a27c5 to 96eeaca Compare October 6, 2026 22:26
Automatically deduplicate dependencies with the highest strategy during
full-project installs, including lazy installs, before linking and
building. Preserve focused installs and explicit dedupe checks and patterns.
Skip automatic deduplication for temporary dlx installs. Keep the up-to-date
install fast path when no deduplication remains.

Fixes yarnpkg#343

Co-authored-by: Codex <noreply@openai.com>
@latin-1
latin-1 force-pushed the feat/enable-auto-dedupe branch from 96eeaca to a3cae15 Compare October 6, 2026 22:40
@latin-1

latin-1 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Rebased. Like in #348, I also made yarn dlx skip dedupe.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to automatically dedupe packages after yarn install

2 participants