Skip to content

Stale-link prune: dedupe compares raw link: paths; hoisted link: removals are not reported #289

Closed
pnpm/pnpm
#17801

Description

@zkochan

Found in review of pnpm/pnpm#17777 (#285, step 3).

Dedupe compares raw link: paths

Under dedupeDirectDeps, the stale-link prune removes a project's direct-dependency link when the root records the same version. A link: version is a path relative to its importer, but the prune compares the raw strings:

  • pnpm v12: unlink_stale_direct_deps in pnpm/crates/deps-restorer/src/prune_stale_modules.rs.
  • pnpm v11: shouldRemoveCurrentPkg in pnpm11/installing/linking/modules-cleaner/src/prune.ts.

The link pass compares the resolved targets instead (dedupe_resolved_entries in v12, symlinkDirectDependencies in v11). The two disagree in both directions:

  • The root and a project both record link:local, each meaning its own local folder. The prune removes the project's valid link on every install, and the link pass recreates it along with its bins.
  • The root records link:packages/a and packages/b records link:../a. These name the same target, so the link pass no longer creates the project's link, but the prune never removes one an earlier install created.

Fix in both stacks: resolve each link: version against its importer's directory before comparing. Once that lands, the hoisted linker can pass dedupe_direct_deps from config to StaleDirectDepLinks (pnpm/pnpm#17777 keeps it off for now).

Hoisted link: removals are not reported

Under nodeLinker: hoisted, a removed link: dependency gets no pnpm:root removed event in either stack. The stale-link prune is silent, and report_direct_dependency_changes (v12) / reportDirectDependencyChanges (v11) skip link: dependencies, because the symlink pass reports them. That pass reports only additions.


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

Activity

  1. zkochan commented on Nov 6, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17801 fixes both parts of this task in both stacks:

    • The stale-link prune now resolves each link: version against its importer's directory before comparing it with the root's, as the link pass does.
    • The hoisted linker's stale-link pass now applies dedupeDirectDeps and reports each link: dependency it removes.

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

  2. added a commit that references this issue on Nov 6, 2026
    e6b8c18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions