Skip to content

fix(lockfile): accept an aliased file: child of an injected package - #17136

Merged
zkochan merged 2 commits into
pnpm:mainfrom
lazerg:fix/issue-17130-aliased-file-child
Oct 20, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
lazerg:fix/issue-17130-aliased-file-child

Conversation

@lazerg

@lazerg lazerg commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #17130.

With injectWorkspacePackages: true and sharedWorkspaceLockfile: false, an injected package that depends on a local directory under another name ("renamed": "file:../b") gets the child recorded as renamed: b@file:../b. The freshness check from #17065 passed that ref to getLocalPath, which only accepted refs starting with file: or link:, so the path never matched and a frozen install right after a normal one failed with ERR_PNPM_OUTDATED_LOCKFILE. getLocalPath now also reads the path from a name@file: ref, the way pnpm v12 already reads it from an aliased lockfile ref.

I reproduced it with the v11 CLI built from main: pnpm install in the issue's layout, then pnpm install --frozen-lockfile in app fails with "The dependencies of local directory dependency "a" do not match the lockfile". With the fix it passes, and pointing the child at another directory still fails. The new test in allProjectsAreUpToDate.test.ts fails without the fix. #17065 shipped in v11.28.6, so the PR includes a changeset.

Squash Commit Body

An injected package's file: child installed under another alias is
recorded as name@file:<path>. getLocalPath only read refs that start
with file: or link:, so the freshness check could not compare the path
and reported a lockfile pnpm had just written as outdated, failing the
next frozen install. It now also reads the path from a name@file: ref.

Closes pnpm/pnpm#17130

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added or updated tests.

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed frozen installs failing with ERR_PNPM_OUTDATED_LOCKFILE when an injected workspace package references a local directory under an alias.
    • Improved lockfile verification for aliased file dependencies, ensuring projects are correctly recognized as up to date when paths match.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3c77fd82-2d32-4cf8-83b0-85b9175543a1
📥 Commits

Reviewing files that changed from the base of the PR and between b3f7a06 and 57e12cf.

📒 Files selected for processing: 1
  • .changeset/aliased-file-child-frozen-install.md
+----------------------------+
| Copilot has nothing on me. |
+----------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2db59943-87d0-408c-b71a-8f8ecea1fb1a
📥 Commits

Reviewing files that changed from the base of the PR and between d6a5e02 and 53be2a4.

📒 Files selected for processing: 2
  • pnpm11/lockfile/verification/src/dependencySpec.ts
  • pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

getLocalPath now extracts paths from aliased @file: dependency specs. A regression test checks that freshness verification accepts a matching local path and rejects a different path.

Changes: Aliased file freshness

Layer / File(s) Summary
Parse and verify aliased paths
pnpm11/lockfile/verification/src/dependencySpec.ts, pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts
getLocalPath now recognizes paths after @file:. The regression test checks matching and mismatching aliased file paths in the lockfile.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
Accept fresh aliased local-file references during freshness checks [#17130] ✅

Suggested labels: product: pnpm@11

Merge Risk: ⚪ Minimal · up to 53be2

The aliased local-file freshness check appears ready to merge after normal checks.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lazerg
lazerg marked this pull request as ready for review October 19, 2026 15:03
@lazerg
lazerg requested a review from zkochan as a code owner October 19, 2026 15:03
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 19, 2026
@zkochan
zkochan force-pushed the fix/issue-17130-aliased-file-child branch from 53be2a4 to b3f7a06 Compare October 19, 2026 21:37

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 🔗 Cross-repo conflicts (0) 📜 Skill insights (1)

Grey Divider


Remediation recommended

1. The changeset merges past and present 📘 Rule violation ⚙ Maintainability
Description
The changeset entry describes the regression only through no longer fails instead of giving the
previous failure its own past-tense sentence. Readers must infer the historical behavior from the
corrected outcome, which makes the release note less clear about what was fixed.
Code

.changeset/aliased-file-child-frozen-install.md[6]

+`pnpm install --frozen-lockfile` no longer fails with `ERR_PNPM_OUTDATED_LOCKFILE` when an injected workspace package depends on a local directory under another name, such as `"renamed": "file:../b"` [#17130](https://github.com/pnpm/pnpm/issues/17130).
Evidence
The changeset's only descriptive sentence combines the corrected behavior with the implied
historical failure through no longer fails, rather than presenting the old behavior as a separate
past-tense sentence. This violates the requirement that previous buggy behavior be described
separately in bug-fix release notes.

Rule 3058498: Describe previous buggy behavior in a separate past-tense sentence
.changeset/aliased-file-child-frozen-install.md[6-6]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset describes the previous frozen-install failure with the phrase `no longer fails` in the same sentence as the corrected behavior. The release note should state the prior failure in a separate past-tense sentence, followed by the current behavior.

## Fix Focus Areas
- .changeset/aliased-file-child-frozen-install.md[6-6]

## Recommended Fix
Rewrite the entry as two sentences: first state that `pnpm install --frozen-lockfile` previously failed with `ERR_PNPM_OUTDATED_LOCKFILE` for the aliased local-directory dependency, then state that it now succeeds for that scenario.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Malformed lockfiles pass frozen checks 🐞 Bug ⛨ Security
Description
getLocalPath accepts any dependency reference containing @file: and returns its suffix without
validating the package identity before the marker. A crafted reference such as
[email protected]@file:packages/foo can therefore enter the local-path workspace branch, bypass the
expected-name check, and be treated as current when the target directory contains the expected
package.
Code

pnpm11/lockfile/verification/src/dependencySpec.ts[R20-21]

+  const aliasEnd = lockfileDep.indexOf('@file:', 1)
+  return aliasEnd === -1 ? null : lockfileDep.slice(aliasEnd + 6)
Evidence
The new parser accepts arbitrary text before @file:. localSpecIsUpToDate passes the cleaned
reference to getLocalPath; for workspace dependencies, a non-null path takes the local-path branch
and returns based on the target manifest before the later hasExpectedName check. The existing path
helper preserves such malformed references as dependency-path keys, so a crafted lockfile entry can
reach this verification path.

pnpm11/lockfile/verification/src/dependencySpec.ts[16-22]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[244-259]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[278-300]
pnpm11/deps/path/src/index.ts[145-153]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`getLocalPath` treats any string containing `@file:` as a valid aliased local reference. This allows malformed lockfile dependency identities to be interpreted as local paths, which can bypass the normal package-name validation during frozen-lockfile freshness checks.

## Fix Focus Areas
- pnpm11/lockfile/verification/src/dependencySpec.ts[20-21]
- pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[278-300]

## Recommended Fix
Restrict aliased parsing to the valid lockfile reference shape produced by pnpm, preserving support for scoped package names and peer suffix removal. Return `null` for malformed prefixes or otherwise ensure the expected package-name validation still runs for them, and add regression coverage for malformed `@file:` references alongside the valid aliased-file case.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. Windows aliased paths stay untested 📜 Skill insight ▣ Testability
Description
The new aliased-file regression test uses only forward-slash paths such as file:../other-dir and
other@file:other-dir. When this path parsing runs on Windows, no Windows separator variant or
platform-specific case exercises the changed behavior, so separator regressions can reach users
undetected.
Code

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[R1379-1382]

+    await writeLocalDirManifest({ dependencies: { renamed: 'file:../other-dir' } })
+    const localDirSnapshot = options.wantedLockfile.packages!['local@file:./local-dir' as DepPath]
+    const check = async (ref: string) => allProjectsAreUpToDate(projects, {
+      ...options,
Evidence
The changed behavior parses local dependency paths, but the added regression test exercises only
../other-dir and other-dir with POSIX separators. The checklist requires an explicit Windows
case for path parsing changes.

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1376-1394]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The aliased local-file regression test covers only POSIX-style separators even though the production change parses and resolves filesystem paths. Add explicit Windows-specific coverage so separator handling is verified on that platform.

## Fix Focus Areas
- pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1376-1394]

## Recommended Fix
Add a Windows-specific test case or platform-aware test data using Windows path separators and the corresponding aliased `name@file:` reference, while preserving the existing POSIX assertions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 52 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: 🚀 Fast: Localized parsing fix with contained lockfile verification behavior and focused regression coverage.

Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan

zkochan commented Oct 19, 2026

Copy link
Copy Markdown
Member

Reviewed and rebased onto main (head b3f7a0606a). No code changes were needed.

  • The fix is correct: localSpecIsUpToDate strips the peer suffix before getLocalPath, so name@file:<path>(peers) refs are handled too.
  • pnpm v12 needs no change: an aliased snapshot ref exposes its VersionPart::File through SnapshotDepRef::ver_peer(), which the directory-dep freshness check already compares.
  • CI is green. The first run's failures were timeouts in denoRuntime.ts (known teardown flake) and the git-protocol licenses test; both passed on rerun.
  • Reviews on the current head: CodeRabbit approved, Qodo found nothing, Greptile's trial has ended. No open threads. The PR stays ready for review; nothing remains within scope.

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

pnpm#17065 shipped in v11.28.6, so the regression it caused is
user-visible and needs a release note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 57e12cf

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

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

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v11 main: injected freshness checker rejects a fresh aliased file: child (after #17065)

2 participants