Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

autoDedupe does not work when downgrading a dependency in one package that is a peer dependency of another #16432

Closed

Description

@haines

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/haines/pnpm-auto-dedupe

Reproduction steps

$ git clone https://github.com/haines/pnpm-auto-dedupe.git
$ cd pnpm-auto-dedupe
$ pnpm install

$ grep "@cerbos/embedded-server@" pnpm-lock.yaml
  '@cerbos/embedded-server@0.7.2':
  '@cerbos/embedded-server@0.7.2(@bufbuild/protobuf@2.16.0)(@cerbos/api@0.11.1)':

$ pnpm --filter=./packages/a add @cerbos/embedded-server@0.7.1
✓ Lockfile passes supply-chain policies (verified 31s ago)
Packages: +1
+
Progress: resolved 1, reused 1, downloaded 0, added 1, done
Done in 52ms using pnpm v12.8.1

$ grep "@cerbos/embedded-server@" pnpm-lock.yaml
  '@cerbos/embedded-server@0.7.1':
  '@cerbos/embedded-server@0.7.2':
  '@cerbos/embedded-server@0.7.1(@bufbuild/protobuf@2.16.0)(@cerbos/api@0.11.1)':
  '@cerbos/embedded-server@0.7.2(@bufbuild/protobuf@2.16.0)(@cerbos/api@0.11.1)':

$ pnpm dedupe
✓ Lockfile passes supply-chain policies (verified 40s ago)
Packages: -1
-
Progress: resolved 3, reused 3, downloaded 0, added 0, done
Done in 53ms using pnpm v12.8.1

$ grep "@cerbos/embedded-server@" pnpm-lock.yaml
  '@cerbos/embedded-server@0.7.1':
  '@cerbos/embedded-server@0.7.1(@bufbuild/protobuf@2.16.0)(@cerbos/api@0.11.1)':

With autoDedupe enabled, we'd expect the final pnpm dedupe to be a no-op, but the deduplication doesn't happen after pnpm add.

Describe the Bug

We have two packages in the monorepo. Package a has a dependency "@cerbos/embedded-server": "0.7.2", package b has a peer dependency "@cerbos/embedded-server": "^0.7.1".

When we run pnpm --filter=./packages/a add @cerbos/embedded-server@0.7.1 to downgrade the dependency, with autoDedupe enabled my expectation is that we end up only having one version of the dependency installed (0.7.1).

In reality, we end up with both 0.7.1 and 0.7.2 installed. Running pnpm dedupe solves this, but we wouldn't expect to have to do so with autoDedupe enabled.

Expected Behavior

pnpm add deduplicates dependencies when autoDedupe is enabled.

Which Node.js version are you using?

v26.10.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

Ubuntu 24

Contributing a fix

  • I am working on a fix

Activity

  1. added theissue type on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. zkochan commented on Sep 30, 2026

    @zkochan
    Member

    Thanks for the clear reproduction. A fix is open in #16438 and covers the whole issue.

    Two things kept 0.7.2 around:

    • When autoDedupe found both versions, it dropped the extra preference that a's exact 0.7.1 spec gives that version. The two versions tied, and ties go to the highest version. pnpm dedupe keeps that preference, which is why it picked 0.7.1.
    • pnpm --filter=./packages/a add wrote back b's old lockfile entry, because b was outside the filter. With autoDedupe on, projects outside the filter now get their deduplicated entries too.

    After the fix, your reproduction ends with only @cerbos/embedded-server@0.7.1 in the lockfile, whether b has it as a peer dependency or a regular one.


    Written by an agent (Claude Code, claude-opus-5-5).

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions