Repository navigation
Conversation
…s importer-independent Under resolvePeersFromWorkspaceRoot, the workspace root's direct dependencies are the first candidates for another importer's missing peer. Which of them may stand in differed between the two stacks: the TypeScript CLI applied no filter at all, while pacquet dropped every link:, file:, and workspace: specifier. Both now use the same rule. link: and file: — and the path form of workspace: (workspace:./pkg, workspace:../pkg) — name a directory relative to the project that declares them, so hoisting one into a sibling importer re-resolves it against that importer's directory and reaches a different path, or none: a root `link:ajv-local` became `ajv@pkg+ajv-local` for the importer it was hoisted into, a link pointing at a directory that does not exist. Those are dropped in both stacks. A workspace: range (workspace:^8.5.10) is not path-relative — it selects the same workspace package from every importer — so it stays a candidate in both stacks, and pacquet no longer resolves a second copy off the registry for a peer the root already provides from the workspace. The same candidate list bounds optional-peer hoisting, so getHoistableOptionalPeers picks up the rule with no change of its own. Closes #13373.
📝 WalkthroughWalkthroughThe resolver pins project-relative ChangesWorkspace peer hoisting
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant WorkspaceImporter
participant LocalPackageManifest
participant PeerResolution
participant Installer
WorkspaceImporter->>LocalPackageManifest: read project-relative dependency manifest
LocalPackageManifest-->>WorkspaceImporter: return package version or manifest error
WorkspaceImporter->>PeerResolution: pass pinned root dependency
PeerResolution-->>Installer: resolve peer dependency tree
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
PR Summary by QodoFix peer hoisting: ignore project-relative root specs (link/file/workspace:./)
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported versionless-path issue is addressed by clearing the candidate before manifest validation, and downstream peer selection excludes candidates without a normalized specifier. Reviews (4): Last reviewed commit: "style(resolving-deps-resolver): add the ..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Unbounded manifest read fanout
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13387 +/- ##
==========================================
+ Coverage 87.22% 87.25% +0.03%
==========================================
Files 536 540 +4
Lines 92059 92662 +603
==========================================
+ Hits 80297 80855 +558
- Misses 11762 11807 +45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5146719885400004,
"stddev": 0.17890334507587285,
"median": 2.4364579710400003,
"user": 1.4696495799999998,
"system": 1.30663662,
"min": 2.3424648970399997,
"max": 2.7773003740399997,
"times": [
2.36035291604,
2.34760931504,
2.48793291604,
2.38498302604,
2.63329188904,
2.76716641704,
2.3424648970399997,
2.7773003740399997,
2.66809095104,
2.37752718404
]
},
{
"command": "pacquet@main",
"mean": 2.6041054462399997,
"stddev": 0.15313681951444919,
"median": 2.65192052604,
"user": 1.4789612799999998,
"system": 1.30441532,
"min": 2.3423185210399997,
"max": 2.77369026904,
"times": [
2.77369026904,
2.41587027604,
2.71737058004,
2.5569018190399997,
2.59433766604,
2.74195190904,
2.3423185210399997,
2.46631947904,
2.70950338604,
2.72279055704
]
},
{
"command": "pnpr@HEAD",
"mean": 1.50562875194,
"stddev": 0.14309034749575078,
"median": 1.4819925405399998,
"user": 1.01217948,
"system": 1.18021272,
"min": 1.36668426704,
"max": 1.81465874504,
"times": [
1.49769764804,
1.36668426704,
1.3704740070399999,
1.54007741904,
1.65388064104,
1.46628743304,
1.54990211504,
1.37155344504,
1.81465874504,
1.42507179904
]
},
{
"command": "pnpr@main",
"mean": 1.5683603545400002,
"stddev": 0.1554448851391461,
"median": 1.58863341704,
"user": 1.0457895799999999,
"system": 1.15722292,
"min": 1.3522055390399998,
"max": 1.73118014904,
"times": [
1.69033020204,
1.53019710904,
1.3522055390399998,
1.73118014904,
1.39065354504,
1.36063247904,
1.5504687290399999,
1.72368942904,
1.72744825904,
1.62679810504
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25198526246,
"stddev": 0.006685150490839992,
"median": 0.25503159596,
"user": 0.21486171999999995,
"system": 0.5027994599999999,
"min": 0.23969130796000002,
"max": 0.25970951096,
"times": [
0.24527569896,
0.25680179996,
0.23969130796000002,
0.24763991496,
0.25787569396,
0.25428735296,
0.24643484696,
0.25636065896,
0.25577583896,
0.25970951096
]
},
{
"command": "pacquet@main",
"mean": 0.25894595536000004,
"stddev": 0.0076853400776414095,
"median": 0.25984461546000004,
"user": 0.21525381999999998,
"system": 0.5171389599999999,
"min": 0.24769230896,
"max": 0.27119048496000003,
"times": [
0.26448192896,
0.24769230896,
0.25381384296,
0.26350290996000003,
0.26573099596,
0.25153175396,
0.27119048496000003,
0.25182609696,
0.26330444696,
0.25638478396000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27299491176,
"stddev": 0.005654150504433411,
"median": 0.27385423546,
"user": 0.22334932000000002,
"system": 0.53742166,
"min": 0.26184768996,
"max": 0.28404283696,
"times": [
0.27379053096,
0.26895175796,
0.27477206496,
0.28404283696,
0.27579395496000003,
0.26184768996,
0.26962506296,
0.27409637496,
0.27311090396,
0.27391793996
]
},
{
"command": "pnpr@main",
"mean": 0.27060628626,
"stddev": 0.011285210165614665,
"median": 0.26925948146,
"user": 0.23996051999999998,
"system": 0.49149626,
"min": 0.25467360796,
"max": 0.28703846596,
"times": [
0.26406995496,
0.26468681396,
0.25942135796,
0.25467360796,
0.26186536296,
0.27530583796,
0.27914865896,
0.27383214896,
0.28602065296,
0.28703846596
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.76203982616,
"stddev": 0.014761340948039721,
"median": 2.7640169096600005,
"user": 1.69384258,
"system": 1.30798778,
"min": 2.73591124116,
"max": 2.7827307301600004,
"times": [
2.73591124116,
2.7694591511600004,
2.7532272001600004,
2.76700191416,
2.7797798351600003,
2.7827307301600004,
2.7610319051600003,
2.77125791116,
2.7489323631600002,
2.75106601016
]
},
{
"command": "pacquet@main",
"mean": 2.76551560646,
"stddev": 0.020278234726145573,
"median": 2.76794975466,
"user": 1.7225677799999999,
"system": 1.2704357799999997,
"min": 2.7214200031600004,
"max": 2.7930954911600003,
"times": [
2.7501810581600004,
2.7690559881600003,
2.7677934961600004,
2.7214200031600004,
2.76810601316,
2.7593306071600003,
2.75901670616,
2.78484166416,
2.7930954911600003,
2.78231503716
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6135359185600002,
"stddev": 0.12118649496543672,
"median": 1.5806567606600002,
"user": 1.00837238,
"system": 1.1756284799999999,
"min": 1.45563726116,
"max": 1.8437581631600002,
"times": [
1.8437581631600002,
1.77524050916,
1.51301213116,
1.5859664611600002,
1.45563726116,
1.66209688716,
1.65102869316,
1.5753470601600001,
1.54607775216,
1.52719426716
]
},
{
"command": "pnpr@main",
"mean": 1.53552590426,
"stddev": 0.11323094451024514,
"median": 1.50460289366,
"user": 1.0504278799999998,
"system": 1.14378528,
"min": 1.44245535716,
"max": 1.8238380391600002,
"times": [
1.44245535716,
1.45738061716,
1.52336326816,
1.48434428416,
1.50729476016,
1.58477225716,
1.8238380391600002,
1.58398635016,
1.50191102716,
1.44591308216
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5895763278399999,
"stddev": 0.00922232692553926,
"median": 0.58441086044,
"user": 0.7171172599999999,
"system": 0.6644636599999998,
"min": 0.58093309194,
"max": 0.60815665594,
"times": [
0.58270094394,
0.58093309194,
0.60815665594,
0.58460997894,
0.58409637494,
0.60162188894,
0.58421174194,
0.58343746794,
0.59092481294,
0.59507032094
]
},
{
"command": "pacquet@main",
"mean": 0.59288383254,
"stddev": 0.009669806743820458,
"median": 0.59435912494,
"user": 0.69346396,
"system": 0.7031755599999998,
"min": 0.57361426294,
"max": 0.60680303294,
"times": [
0.57361426294,
0.58807362694,
0.58463799194,
0.59865092794,
0.60680303294,
0.59685120594,
0.60296521294,
0.58852381394,
0.59197609794,
0.59674215194
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30648158034,
"stddev": 0.005841396985712474,
"median": 0.30591929444000004,
"user": 0.19770406000000001,
"system": 0.5470994599999999,
"min": 0.29590720394000003,
"max": 0.31342758894000006,
"times": [
0.31342758894000006,
0.30395906194000005,
0.30340285694,
0.30346529394000005,
0.30952866494000003,
0.31337859794000006,
0.29590720394000003,
0.30787952694000004,
0.31254050294,
0.30132650494
]
},
{
"command": "pnpr@main",
"mean": 0.30633498004000004,
"stddev": 0.009271140426703215,
"median": 0.30438334844000003,
"user": 0.20006165999999997,
"system": 0.52559706,
"min": 0.29229495794000004,
"max": 0.31926309194,
"times": [
0.31738764894000004,
0.29229495794000004,
0.30362900194000003,
0.31926309194,
0.29975264094000004,
0.30234379694,
0.31657425294,
0.29648164794000004,
0.30513769494000004,
0.31048506594
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9127387598600003,
"stddev": 0.010989967049315192,
"median": 1.91123570736,
"user": 0.92884066,
"system": 0.78661428,
"min": 1.8982907253599999,
"max": 1.9318201253599998,
"times": [
1.9318201253599998,
1.92697200036,
1.9181441713599998,
1.91618788736,
1.9079070653599999,
1.8982907253599999,
1.91332567236,
1.8985428393600001,
1.90705136936,
1.90914574236
]
},
{
"command": "pacquet@main",
"mean": 1.9020357064599995,
"stddev": 0.007815970661460338,
"median": 1.90162041986,
"user": 0.94065136,
"system": 0.7447369799999999,
"min": 1.8886662913599999,
"max": 1.9128081103599999,
"times": [
1.90744077036,
1.8994724563599998,
1.9120915643599998,
1.90312156936,
1.8919759963599998,
1.9001192703599998,
1.89989228436,
1.9128081103599999,
1.8886662913599999,
1.90476875136
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3027396552600001,
"stddev": 0.005044520528005847,
"median": 0.30167035336000003,
"user": 0.19600416,
"system": 0.5467913799999999,
"min": 0.29487118336,
"max": 0.31217473036000004,
"times": [
0.30847849936000005,
0.30015908536,
0.29487118336,
0.30231984336,
0.29880135436000005,
0.30302662036000005,
0.31217473036000004,
0.30102086336000006,
0.30637116136000003,
0.30017321136
]
},
{
"command": "pnpr@main",
"mean": 0.30360850786000004,
"stddev": 0.005215182883868056,
"median": 0.30301560936000005,
"user": 0.20162535999999998,
"system": 0.53266678,
"min": 0.29426705936,
"max": 0.31305432336000005,
"times": [
0.30566951336000003,
0.31305432336000005,
0.30293923636000003,
0.30968555536000003,
0.30269185136000004,
0.30449602936000003,
0.30029894736,
0.29426705936,
0.29989058036000005,
0.30309198236
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35385651606000007,
"stddev": 0.008643050511347054,
"median": 0.35174555586,
"user": 0.34901272,
"system": 0.05105014,
"min": 0.34683966686,
"max": 0.37574137586,
"times": [
0.37574137586,
0.34809028586,
0.34872292386000003,
0.34683966686,
0.35508292786,
0.34737346986,
0.35442756786,
0.34906354386000005,
0.35548926186,
0.35773413686000005
]
},
{
"command": "pacquet@main",
"mean": 0.35760737636,
"stddev": 0.011466361324338472,
"median": 0.35243427836,
"user": 0.35318521999999997,
"system": 0.05039774,
"min": 0.34493147386,
"max": 0.37664924086,
"times": [
0.34755890886,
0.35259400286000003,
0.35114667586000003,
0.36200207286,
0.34975563386,
0.34493147386,
0.36265018886,
0.37664924086,
0.37651101186,
0.35227455386
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08727175361757578,
"stddev": 0.0016489182703031593,
"median": 0.08714680486000001,
"user": 0.021649523030303024,
"system": 0.00781400606060606,
"min": 0.08474479386000001,
"max": 0.09051269586,
"times": [
0.08595570786000001,
0.08638404186000001,
0.08578538786,
0.08789874586000002,
0.08822694386,
0.08952664386,
0.08474479386000001,
0.09051269586,
0.08511130186,
0.08796766586,
0.08585840386000002,
0.08747909786000001,
0.08993384786000001,
0.08690289686000001,
0.08494472886000001,
0.09005600686000001,
0.08502553086,
0.08773555986,
0.08651409686000001,
0.08685912486000001,
0.08804045186000001,
0.08740264486,
0.08653689886,
0.08978191386,
0.08536811386000001,
0.08740264586,
0.08700512786,
0.08931294186000001,
0.08657782586000001,
0.08958026486000001,
0.08521082886,
0.08714680486000001,
0.08717818286000001
]
},
{
"command": "pnpr@main",
"mean": 0.087284922735,
"stddev": 0.0011700973049192968,
"median": 0.08732617586000001,
"user": 0.021631657500000005,
"system": 0.00767156875,
"min": 0.08295401086000001,
"max": 0.08926836886,
"times": [
0.08740298486,
0.08739584186,
0.08722520086,
0.08295401086000001,
0.08744679786000001,
0.08725650986000001,
0.08782390586000001,
0.08697903886000001,
0.08673357886000001,
0.08818314986,
0.08705136486000001,
0.08746460186,
0.08860922986000001,
0.08644851286,
0.08723512086000001,
0.08839194286,
0.08682090286000001,
0.08659390586000001,
0.08823632986,
0.08686559586,
0.08765485886,
0.08818431386000002,
0.08672107486000001,
0.08713891986000001,
0.08760447286,
0.08682458886000001,
0.08799648986000001,
0.08822617086000001,
0.08630547486000001,
0.08926836886,
0.08496529786000001,
0.08910896886000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.57961458542,
"stddev": 0.1431512577233899,
"median": 4.53271856172,
"user": 1.7261493600000002,
"system": 1.3026516799999999,
"min": 4.43750216522,
"max": 4.84677481822,
"times": [
4.64402606422,
4.53639790522,
4.43750216522,
4.84677481822,
4.46078963122,
4.54291399522,
4.81027514022,
4.52903921822,
4.5168886192199995,
4.47153829722
]
},
{
"command": "pacquet@main",
"mean": 4.546506967919999,
"stddev": 0.1519484827363178,
"median": 4.47976392522,
"user": 1.71202606,
"system": 1.33317328,
"min": 4.40007635622,
"max": 4.87123095022,
"times": [
4.55857695222,
4.69578068222,
4.47155972722,
4.48796812322,
4.43638342322,
4.87123095022,
4.40007635622,
4.43570061022,
4.66552263422,
4.44227022022
]
},
{
"command": "pnpr@HEAD",
"mean": 3.4778334822200003,
"stddev": 0.026750317808805043,
"median": 3.47468607822,
"user": 1.1800492599999999,
"system": 1.21096488,
"min": 3.44434912822,
"max": 3.5334709052199997,
"times": [
3.47149250522,
3.5334709052199997,
3.47787965122,
3.45725731022,
3.45461904622,
3.44434912822,
3.49602905722,
3.46080528322,
3.50221077022,
3.48022116522
]
},
{
"command": "pnpr@main",
"mean": 3.5513337819200004,
"stddev": 0.12653451768351967,
"median": 3.5083796197200003,
"user": 1.1776433599999998,
"system": 1.2343654799999997,
"min": 3.45138891022,
"max": 3.83687347322,
"times": [
3.50455523222,
3.83687347322,
3.48846341322,
3.45138891022,
3.5122040072200003,
3.5544460942200002,
3.45612049622,
3.52535908022,
3.71816460822,
3.4657625042199998
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13387 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,455.64 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 294.87 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 295.91 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.74 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,366.68 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,444.35 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 261.85 ms |
…not its path A workspace-root dependency declared with link:, file:, or the path form of workspace: names a directory relative to the root, so hoisting the specifier verbatim re-resolved it against the directory of the importer the peer was hoisted into: a root `link:ajv-local` reached pkg/ajv-local and left a dangling symlink there. Both stacks now substitute the linked package's own version for its path. The root keeps the authority over the peer that it has when it declares the package with a version range — a sibling's newer copy no longer wins over the version the root pins — and the peer resolves to the same package from every importer. The manifest is read from disk rather than taken from the resolved dependency, which a linked dep reused from the lockfile does not have; reading it keeps a repeat install hoisting what a fresh install of the same manifest hoists. A target with no manifest to read (a file: tarball, a path that does not exist) or no valid version in it is not a candidate, and the peer falls through to the ordinary auto-install path. A workspace: range needs none of this: it selects the same workspace package from every importer, so it is hoisted as-is. pacquet previously dropped it and resolved a second copy off the registry for a peer the root already provided from the workspace. The same candidate list bounds optional-peer hoisting, so getHoistableOptionalPeers picks up the rule with no change of its own. Closes #13373.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm11/installing/deps-resolver/src/resolveDependencies.ts (1)
578-594: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: pass the specifier in rather than re-asserting it.
The two
!assertions on Line 582 rely on the guard in the caller at Line 549. Taking the already-narrowed specifier as a parameter removes the assertions and makes the invariant type-checked.♻️ Proposed refactor
async function pinProjectRelativeDepToItsVersion ( rootDep: HoistableRootDep, + bareSpecifier: string, rootDir: string | undefined ): Promise<HoistableRootDep> { - const pathWithoutProtocol = rootDep.normalizedBareSpecifier!.slice(rootDep.normalizedBareSpecifier!.indexOf(':') + 1) + const pathWithoutProtocol = bareSpecifier.slice(bareSpecifier.indexOf(':') + 1)and at the call site:
- return pinProjectRelativeDepToItsVersion(rootDep, rootDir) + return pinProjectRelativeDepToItsVersion(rootDep, rootDep.normalizedBareSpecifier, rootDir)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm11/installing/deps-resolver/src/resolveDependencies.ts` around lines 578 - 594, Update pinProjectRelativeDepToItsVersion to accept the already-narrowed normalized bare specifier as a parameter, and use that parameter when removing the protocol instead of re-reading rootDep.normalizedBareSpecifier with non-null assertions. Update its caller to pass the guarded specifier while preserving the existing manifest resolution and return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm11/installing/deps-resolver/src/resolveDependencies.ts`:
- Around line 578-594: Update pinProjectRelativeDepToItsVersion to accept the
already-narrowed normalized bare specifier as a parameter, and use that
parameter when removing the protocol instead of re-reading
rootDep.normalizedBareSpecifier with non-null assertions. Update its caller to
pass the guarded specifier while preserving the existing manifest resolution and
return behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d7825ade-84ef-40be-a31e-07fd5e1e4845
📒 Files selected for processing (8)
.changeset/peer-hoist-skips-project-relative-root-deps.mdpnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/resolving-deps-resolver/src/resolve_importer.rspnpm/crates/resolving-deps-resolver/src/resolve_importer/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rspnpm11/installing/deps-installer/test/install/peerDependencies.tspnpm11/installing/deps-resolver/src/resolveDependencies.ts
|
Code review by qodo was updated up to the latest commit 6cdfe8c |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Found 1 test failure on Blacksmith runners: Failure
|
…mes no version Both stacks already dropped the candidate in that case — a path must never survive as the hoisted specifier — but only the no-manifest-at-all shape was covered, and pacquet expressed the drop by taking the specifier out of the dep before reading the target, which reads as if the early returns left the path in place. The drop is now written where it happens, and each stack has a test for a target whose manifest carries no version.
…s in a test assertion
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Code review by qodo was updated up to the latest commit 6bf0733 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs`:
- Around line 768-787: The local_target_identity function must treat
tarball-style file targets and paths without a usable package.json as ineligible
root peer candidates rather than propagating Io or Parse errors. Update its
manifest-loading flow to convert those non-directory/package-root failures into
Ok(None), while preserving successful manifest identity extraction and
propagation of unrelated errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1d04b8c0-165a-436b-b82b-2b6304b21397
📒 Files selected for processing (3)
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rspnpm11/installing/deps-installer/test/install/peerDependencies.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
| fn local_target_identity( | ||
| spec: &str, | ||
| project_dir: &Path, | ||
| ) -> Result<Option<LocalTargetIdentity>, PackageManifestError> { | ||
| let path_without_protocol = spec.split_once(':').map_or(spec, |(_, path)| path); | ||
| let Some(manifest) = read_manifest_of_local_target(&project_dir.join(path_without_protocol))? | ||
| else { | ||
| return Ok(None); | ||
| }; | ||
| let Some(version) = manifest.get("version").and_then(serde_json::Value::as_str) else { | ||
| return Ok(None); | ||
| }; | ||
| if version.parse::<Version>().is_err() { | ||
| return Ok(None); | ||
| } | ||
| Ok(Some(LocalTargetIdentity { | ||
| name: manifest.get("name").and_then(serde_json::Value::as_str).map(str::to_string), | ||
| version: version.to_string(), | ||
| })) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
ast-grep run --pattern 'fn read_manifest_of_local_target($$$) { $$$ }' --lang rust pnpm/crates/resolving-deps-resolver/srcRepository: pnpm/pnpm
Length of output: 147
🏁 Script executed:
#!/bin/bash
set -u
echo "== candidate files =="
git ls-files 'pnpm/crates/resolving-deps-resolver/src/*'
echo
echo "== resolve_importer relevant symbols/uses =="
rg -n "read_manifest_of_local_target|local_target_identity|LocalTargetIdentity|fn .*read_manifest" pnpm/crates/resolving-deps-resolver/src || true
echo
echo "== resolve_importer outline =="
ast-grep outline pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs --view compact || true
echo
echo "== relevant lines around local_target_identity =="
sed -n '720,810p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rsRepository: pnpm/pnpm
Length of output: 6608
🏁 Script executed:
#!/bin/bash
set -u
echo "== imports =="
sed -n '1,80p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs || true
echo
echo "== safe_read_package_json_from_dir definition =="
rg -n "fn safe_read_package_json_from_dir|read_package_json|package.json" pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs pnpm/crates -g '*.rs' | head -80 || true
echo
echo "== local_target_identity callsites =="
rg -n "local_target_identity\\(" pnpm/crates/resolving-deps-tracker pnpm/crates/resolving-deps-resolver -g '*.rs' || true
sed -n '830,900p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs || trueRepository: pnpm/pnpm
Length of output: 15266
🏁 Script executed:
#!/bin/bash
set -u
echo "== package manifest helper candidates =="
git ls-files | rg 'package-manifest|package_manifest|package manifest' | head -50
echo
echo "== definitions/usages =="
rg -n "safe_read_package_json_from_dir|read_package_json|PackageManifestError" pnpm/crates -g '*.rs' | head -120 || true
echo
echo "== tarball target handling in local resolver =="
sed -n '220,315p' pnpm/crates/resolving-local-resolver/src/local_resolver.rs || trueRepository: pnpm/pnpm
Length of output: 19131
🏁 Script executed:
#!/bin/bash
set -u
echo "== package manifest safe read implementation =="
sed -n '825,870p' pnpm/crates/package-manifest/src/lib.rs || true
echo
echo "== package manifest error enum =="
sed -n '1,90p' pnpm/crates/package-manifest/src/lib.rs || true
echo
echo "== tests around safe_read_package_json_from_dir error handling =="
sed -n '900,940p' pnpm/crates/package-manifest/src/tests.rs || trueRepository: pnpm/pnpm
Length of output: 7230
Handle tarball-style local deps in root peer pinning.
safe_read_package_json_from_dir only returns Ok(None) for a missing package.json; a file: target that names a tarball archive or a path with no package.json propogates an Io/Parse error through local_target_identity, breaking the workspace root resolve instead of treating the target as ineligible. Match pnpm/local resolver behavior: if the target is not a directory/package root, exclude it from root peer candidates rather than failing the whole resolution.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs` around lines 768
- 787, The local_target_identity function must treat tarball-style file targets
and paths without a usable package.json as ineligible root peer candidates
rather than propagating Io or Parse errors. Update its manifest-loading flow to
convert those non-directory/package-root failures into Ok(None), while
preserving successful manifest identity extraction and propagation of unrelated
errors.
…not its path (pnpm#13387) A workspace-root dependency declared with link:, file:, or the path form of workspace: names a directory relative to the root, so hoisting the specifier verbatim re-resolved it against the directory of the importer the peer was hoisted into: a root `link:ajv-local` reached pkg/ajv-local and left a dangling symlink there. Both stacks now substitute the linked package's own version for its path. The root keeps the authority over the peer that it has when it declares the package with a version range — a sibling's newer copy no longer wins over the version the root pins — and the peer resolves to the same package from every importer. The manifest is read from disk rather than taken from the resolved dependency, which a linked dep reused from the lockfile does not have; reading it keeps a repeat install hoisting what a fresh install of the same manifest hoists. A target with no manifest to read (a file: tarball, a path that does not exist) or no valid version in it is not a candidate, and the peer falls through to the ordinary auto-install path. A workspace: range needs none of this: it selects the same workspace package from every importer, so it is hoisted as-is. pacquet previously dropped it and resolved a second copy off the registry for a peer the root already provided from the workspace. The same candidate list bounds optional-peer hoisting, so getHoistableOptionalPeers picks up the rule with no change of its own. Closes pnpm#13373.
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light.png)
Summary
Under
resolvePeersFromWorkspaceRoot, the workspace root's direct dependencies are the first candidates for another importer's missing peer, and the hoist copies the root's specifier string into that importer and re-resolves it there. So the specifier has to mean the same thing from a different directory — andlink:,file:, and the path form ofworkspace:do not.Demonstrated on the TypeScript side before the fix, with a root
ajv: link:ajv-localand a siblingpkgneedingajvas a peer:Both stacks now substitute the linked package's own version for its path. The root keeps the authority over the peer that it already has when it declares the package with a version range — a sibling's newer copy no longer wins over the version the root pins — and the peer resolves to the same package from every importer:
ajv: 4.10.0ajv: 5.0.0[email protected](unchanged)ajv: link:ajv-local(its manifest says4.10.0)ajv: 5.0.0[email protected](was a dangling link)The manifest is read from disk rather than taken from the resolved dependency, because a linked dep reused from the lockfile has no resolved address (
resolveDependencies.tsshort-circuitsdepIsLinkeddeps) — reading it keeps a repeat install hoisting what a fresh install of the same manifest hoists. A target with no manifest to read (afile:tarball, a path that does not exist) or no valid version in it is not a candidate, and the peer falls through to the ordinary auto-install path.A
workspace:range needs none of this — it selects the same workspace package from every importer, so it is hoisted as-is. pacquet previously dropped it (is_project_relative_specifierexcluded all ofworkspace:) and resolved a second copy off the registry for a peer the root already provided from the workspace.The same candidate list bounds optional-peer hoisting, so
getHoistableOptionalPeers/get_hoistable_optional_peerspick up the rule with no change of their own — this closes the asymmetry a reviewer raised on #13369.Closes #13373.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Tests
Each new test was verified to fail when the behavior is reverted.
installing/deps-installer/test/install/peerDependencies.ts): alink:root dep pinning the peer at its own version, alink:target with no manifest to read, and aworkspace:range case. Full@pnpm/installing.deps-installersuite green (80 suites / 828 tests);@pnpm/installing.deps-resolvergreen (155 tests).resolve_workspace/tests.rs):a_link_root_dep_provides_the_peer_at_the_linked_packages_version,a_workspace_path_root_dep_is_not_offered_as_a_peer_provider, anda_workspace_range_root_dep_is_offered_as_a_peer_provider. Full workspace suite green (7193 tests);cargo fmt,taplo format --check, workspace clippy, and rustdoc clean.Written by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
Bug Fixes
link:,file:, and path-basedworkspace:references, ensuring peers are sourced from the correct package version/context.workspace:ranges.Tests