Skip to content

store prune: find the installed lockfiles of dedicated-lockfile projects and per-project modulesDir #214

Closed
pnpm/pnpm
#17379

Description

@zkochan

Follow-up to pnpm/pnpm#17327, which makes pnpm store prune keep the store files of packages that a registered project's installed lockfile lists, even when they were copied or cloned into node_modules.

That collector finds each project's installed lockfile under the modulesDir set in <registered dir>/pnpm-workspace.yaml. Workspaces with dedicated lockfiles (sharedWorkspaceLockfile: false) are not covered:

  • pnpm 12 registers only the workspace root (pnpm/crates/package-manager/src/install/run/fast_path.rs), so a project's own <modulesDir>/.pnpm/lock.yaml is never read.
  • pnpm 11 registers each project's lockfileDir (pnpm11/installing/context/src/index.ts, prepareStoreDir), but that directory has no pnpm-workspace.yaml, so the workspace-level modulesDir is not seen.
  • Neither stack applies packageConfigs.<project>.modulesDir, which an install resolves through createProjectModulesDirResolver (pnpm 11) and Config::anchor_dedicated_project (pnpm 12).

For these projects the prune falls back to the hard-link count, as it did before pnpm/pnpm#17327, so their copied, cloned, patched, and built packages can still be removed.

A complete fix needs the registered project to point at its effective modules directory, or the prune to resolve the workspace config and packageConfigs the way install does, in both stacks. Recording the effective modulesDir in the project registry would also let the global virtual store prune, which looks only at node_modules, find these projects.


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

Activity

  1. zkochan commented on Oct 26, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17327 now reads modulesDir from the nearest pnpm-workspace.yaml at or above the registered directory (commit 31912dcb28b9782678fec8ca88de3f88c9f47398), so a pnpm 11 member registered on its own gets the workspace-level modulesDir. What remains: packageConfigs.<project>.modulesDir in both stacks, and pnpm 12 registering only the workspace root.


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

  2. self-assigned this
    on Oct 26, 2026
  3. zkochan commented on Oct 26, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17379 makes store prune apply packageConfigs.<project>.modulesDir in both stacks. It applies the entry only when the workspace does not share one lockfile, which matches the install.

    The first point no longer holds. A pnpm 12 install with sharedWorkspaceLockfile: false registers each project as well as the root, as pnpm 11 does. I checked this with a debug build, so registration stays unchanged.

    Out of scope: the global virtual store prune still looks only under directories named node_modules.


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

  4. added a commit that references this issue on Oct 26, 2026
    c6d02b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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