Repository navigation
fix(package-manager): stop nesting hoisted deps that won the root slot - #13306
Conversation
With nodeLinker=hoisted, every workspace project got a link to each of its direct dependencies, including the ones already materialized in the workspace-root node_modules. Node resolution walks up from the project, so that second entry is redundant — and it is a second copy for the build pass to run lifecycle scripts in. pnpm nests a copy only for the versions that lost the root slot. Upstream's map comes from the hoisting hierarchy, so a dependency the hoister moved to the root is simply absent from the importer's entry; pacquet derives it from the importer's lockfile declarations, which keeps the winner in the map, so the link pass has to recognize and skip it. The workspace root itself is exempt: it owns the hoisted slot, and its entries are the real directories rather than links to them. Two tests asserted the old shape and now pin the upstream rule, and the known-failure stub registered for this divergence (hoisted_workspace_duplicate_materialization) becomes a real assertion in run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker. Refs #13167 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughHoisted direct dependency linking now avoids duplicating workspace-root dependency versions in non-root projects. Shared symlink detection is centralized, and tests validate nested materialization for losing versions, root-slot resolution, stale-link removal, and removal of obsolete known-failure gating. ChangesHoisted root-slot deduplication
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 hoisted linker: don't nest root-slot winners in workspace projects
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/cli/tests/hoisted_node_linker.rs`:
- Around line 543-549: Update the loop over nested projects in the hoisted
linker test to assert each project resolves to version 2.0.0 before or alongside
checking its generated build artifacts. Use the existing package-resolution or
manifest assertion helpers and preserve the current requirement that every
nested copy is built.
In `@pnpm/crates/package-manager/src/install_frozen_lockfile.rs`:
- Around line 1838-1842: Validate the alias and construct link_path via
safe_join_modules_dir before the root-slot fast path condition. Update the
branch around the lexical_normalize comparison so malformed or absolute aliases
return InvalidAlias rather than reaching continue; reuse the validated link_path
for the comparison and preserve the existing workspace-root behavior.
🪄 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: 87176378-186f-45c2-9c11-593ec70e1c3d
📒 Files selected for processing (4)
.changeset/pacquet-hoisted-no-duplicate-root-version.mdpnpm/crates/cli/tests/hoisted_node_linker.rspnpm/crates/cli/tests/install_filters.rspnpm/crates/package-manager/src/install_frozen_lockfile.rs
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the current cleanup recognizes both symlinks and Windows junctions, removes stale project-local links, and preserves real nested directories for the existing pruner. Reviews (3): Last reviewed commit: "style: taplo-format the testing-utils ma..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13306 +/- ##
========================================
Coverage 87.02% 87.02%
========================================
Files 531 532 +1
Lines 91442 91642 +200
========================================
+ Hits 79574 79755 +181
- Misses 11868 11887 +19 ☔ 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.54893384904,
"stddev": 0.14944767204023177,
"median": 2.56413595084,
"user": 1.6724535,
"system": 1.3136407599999997,
"min": 2.3563048973400003,
"max": 2.74283837934,
"times": [
2.3865960913400004,
2.73192019434,
2.6423963023400003,
2.64892273934,
2.63765348034,
2.49061842134,
2.3563048973400003,
2.74283837934,
2.48199185134,
2.37009613334
]
},
{
"command": "pacquet@main",
"mean": 2.59745927704,
"stddev": 0.18222093504616887,
"median": 2.6647377058400004,
"user": 1.6602891,
"system": 1.30191166,
"min": 2.36159338134,
"max": 2.7984743243400003,
"times": [
2.3676575053400004,
2.75544362634,
2.7384888323400003,
2.77625866234,
2.4591782973400003,
2.6409058243400003,
2.3880227293400003,
2.36159338134,
2.68856958734,
2.7984743243400003
]
},
{
"command": "pnpr@HEAD",
"mean": 1.51503685004,
"stddev": 0.15503567208498403,
"median": 1.48613078634,
"user": 1.1887124,
"system": 1.15514896,
"min": 1.3525032423399999,
"max": 1.74950385334,
"times": [
1.6947030733400001,
1.40017162434,
1.52960186634,
1.5021088873400001,
1.35798206334,
1.47015268534,
1.74950385334,
1.3525032423399999,
1.72057061734,
1.37307058734
]
},
{
"command": "pnpr@main",
"mean": 1.45463108694,
"stddev": 0.15438022695569706,
"median": 1.4071474848399999,
"user": 1.1844687999999999,
"system": 1.14605526,
"min": 1.34117073534,
"max": 1.77814361934,
"times": [
1.42727150234,
1.69384358634,
1.44279620134,
1.34117073534,
1.35327600134,
1.42963824234,
1.38702346734,
1.35065970534,
1.77814361934,
1.34248780834
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2520189105,
"stddev": 0.008164913930436318,
"median": 0.252074615,
"user": 0.19484428000000004,
"system": 0.52341648,
"min": 0.240303168,
"max": 0.264312895,
"times": [
0.264312895,
0.243519954,
0.252649287,
0.240303168,
0.258985032,
0.244798974,
0.261954294,
0.255417169,
0.246748389,
0.251499943
]
},
{
"command": "pacquet@main",
"mean": 0.24498405029999998,
"stddev": 0.006983357582208611,
"median": 0.24602258300000002,
"user": 0.18721378,
"system": 0.51134878,
"min": 0.234372501,
"max": 0.25429303600000003,
"times": [
0.251656655,
0.234372501,
0.237350698,
0.246293189,
0.250244653,
0.249130363,
0.245751977,
0.25429303600000003,
0.24523025,
0.235517181
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26621399879999996,
"stddev": 0.007963278453245628,
"median": 0.266954912,
"user": 0.21514987999999996,
"system": 0.49643708000000003,
"min": 0.254632641,
"max": 0.27767423,
"times": [
0.254632641,
0.267507958,
0.27767423,
0.263242502,
0.261921934,
0.269003957,
0.269339113,
0.277582162,
0.266401866,
0.254833625
]
},
{
"command": "pnpr@main",
"mean": 0.2702926885,
"stddev": 0.007406219013765955,
"median": 0.268013958,
"user": 0.19453828,
"system": 0.53276868,
"min": 0.26358251,
"max": 0.28605900700000003,
"times": [
0.270010719,
0.270656583,
0.26358251,
0.267769884,
0.263649833,
0.266769985,
0.280740762,
0.268258032,
0.26542957,
0.28605900700000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7541932812800005,
"stddev": 0.007366001975724782,
"median": 2.75529446128,
"user": 1.8565308999999999,
"system": 1.33992914,
"min": 2.7403200672800003,
"max": 2.7650797272800003,
"times": [
2.75765690928,
2.7545895772800004,
2.7559993452800002,
2.75633359528,
2.74389148428,
2.7650797272800003,
2.75256166028,
2.75434055828,
2.7611598882800004,
2.7403200672800003
]
},
{
"command": "pacquet@main",
"mean": 2.74479608048,
"stddev": 0.008088338527941843,
"median": 2.74581520828,
"user": 1.8354217,
"system": 1.2983878399999997,
"min": 2.7330958952800004,
"max": 2.75508070528,
"times": [
2.75365603328,
2.7446687932800002,
2.7330958952800004,
2.7466755052800003,
2.75508070528,
2.74667503028,
2.73466817128,
2.73537322928,
2.7531120552800004,
2.74495538628
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7073701408799997,
"stddev": 0.12351185098685981,
"median": 1.77216211528,
"user": 1.1821888,
"system": 1.1597037399999999,
"min": 1.51961446328,
"max": 1.82454369128,
"times": [
1.80207177428,
1.51961446328,
1.82454369128,
1.67918458928,
1.76946568128,
1.77485854928,
1.5211657002799999,
1.8010772712799998,
1.80519071228,
1.5765289762799999
]
},
{
"command": "pnpr@main",
"mean": 1.6059466053800002,
"stddev": 0.14942431265005332,
"median": 1.5518943322799998,
"user": 1.1912979,
"system": 1.1332004399999998,
"min": 1.44468965028,
"max": 1.88444848428,
"times": [
1.88444848428,
1.50015324928,
1.44468965028,
1.68252180728,
1.67415385528,
1.50685159328,
1.59109894228,
1.46463993228,
1.79821881728,
1.51268972228
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.58867044294,
"stddev": 0.014702609371322091,
"median": 0.59089019814,
"user": 0.7221323199999998,
"system": 0.6685702400000001,
"min": 0.56230232914,
"max": 0.61321881214,
"times": [
0.5734518561399999,
0.58399855914,
0.59515824814,
0.60090790614,
0.58937669214,
0.61321881214,
0.57827807614,
0.59240370414,
0.56230232914,
0.59760824614
]
},
{
"command": "pacquet@main",
"mean": 0.56989804094,
"stddev": 0.009926307468278592,
"median": 0.56788775064,
"user": 0.6887779199999999,
"system": 0.6676998399999999,
"min": 0.5583338691399999,
"max": 0.5866866831399999,
"times": [
0.5733104811399999,
0.56408624014,
0.56590435714,
0.56987114414,
0.55923704814,
0.58172937614,
0.5866866831399999,
0.5787476311399999,
0.5583338691399999,
0.56107357914
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29464731454000004,
"stddev": 0.007373423210208567,
"median": 0.29342083564000004,
"user": 0.18110621999999996,
"system": 0.50182914,
"min": 0.28332137614,
"max": 0.30513655814,
"times": [
0.29785696014,
0.28517744914000004,
0.30013782914000003,
0.29274466414000005,
0.29221000814000003,
0.28332137614,
0.30460059214,
0.29119070114,
0.29409700714000003,
0.30513655814
]
},
{
"command": "pnpr@main",
"mean": 0.29952672403999997,
"stddev": 0.008751511036669187,
"median": 0.29926834814000003,
"user": 0.18180871999999998,
"system": 0.52538014,
"min": 0.28921529014,
"max": 0.31433722814000004,
"times": [
0.31433722814000004,
0.30286378914,
0.28921529014,
0.30173213814000005,
0.29680455814,
0.31213784114000004,
0.29069651814,
0.29140522214000003,
0.29398729314000005,
0.30208736214000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9077918317599998,
"stddev": 0.009946998542120618,
"median": 1.9083953991600002,
"user": 0.9447758399999998,
"system": 0.7605408199999999,
"min": 1.89413717516,
"max": 1.9200241931600002,
"times": [
1.89413717516,
1.9095676941600002,
1.89683840916,
1.89810444416,
1.91982104016,
1.9166732241600002,
1.91529851116,
1.9002305221600002,
1.90722310416,
1.9200241931600002
]
},
{
"command": "pacquet@main",
"mean": 1.89243709896,
"stddev": 0.01552115349051835,
"median": 1.89320727016,
"user": 0.9363406399999998,
"system": 0.73658442,
"min": 1.87461925216,
"max": 1.9198907901600002,
"times": [
1.90102128716,
1.9198907901600002,
1.88810013016,
1.87461925216,
1.87489450416,
1.88325597316,
1.89831441016,
1.87649405216,
1.8983510351600001,
1.90942955516
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29972097676000004,
"stddev": 0.008577964324366319,
"median": 0.29779545766000004,
"user": 0.18486483999999997,
"system": 0.50178992,
"min": 0.28514282316,
"max": 0.31620397716000004,
"times": [
0.29600676416000005,
0.29635217916,
0.30168269416000004,
0.29332221116,
0.30862350916000003,
0.29833713416,
0.29725378116,
0.28514282316,
0.30428469416000004,
0.31620397716000004
]
},
{
"command": "pnpr@main",
"mean": 0.29604121306,
"stddev": 0.0066938466062139625,
"median": 0.29635256316,
"user": 0.18909854000000004,
"system": 0.5107025199999999,
"min": 0.28586689616,
"max": 0.30625943616,
"times": [
0.29362675416,
0.29423602016,
0.30625943616,
0.30259884116,
0.29846910616,
0.29374604616,
0.28586689616,
0.29853610516,
0.30106355116,
0.28600937416
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35883458714000005,
"stddev": 0.005407291891711202,
"median": 0.35812290404,
"user": 0.34523057999999995,
"system": 0.077464,
"min": 0.35026917254000006,
"max": 0.37182455054,
"times": [
0.35652606254,
0.35713902654,
0.35833047854000005,
0.36082121754,
0.35827822954000005,
0.35796757854000005,
0.36052641954000003,
0.37182455054,
0.35026917254000006,
0.35666313554000006
]
},
{
"command": "pacquet@main",
"mean": 0.35998714474,
"stddev": 0.005932195720258952,
"median": 0.35799642254,
"user": 0.34567628,
"system": 0.07041449999999999,
"min": 0.35348812454000006,
"max": 0.37368935554000005,
"times": [
0.36079507954000006,
0.37368935554000005,
0.35728193754000004,
0.35603890354000006,
0.35677206554,
0.35348812454000006,
0.36621756854000004,
0.36038713954,
0.35871090754,
0.35649036554
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08761799154000004,
"stddev": 0.0022599110767084463,
"median": 0.08695890754,
"user": 0.021880583225806455,
"system": 0.009141519354838711,
"min": 0.08418882354000001,
"max": 0.09241881954,
"times": [
0.09127004854000001,
0.08819068554000001,
0.08654592954000001,
0.08574594654,
0.08695890754,
0.08581143754000001,
0.08720107054000001,
0.08587820054,
0.08762157454000001,
0.09080935354000001,
0.09146413854,
0.08623553054000001,
0.08677686854000001,
0.08706517554000001,
0.09054012054,
0.08750316054000001,
0.08669397754000001,
0.09167338054,
0.08765787554000001,
0.08418882354000001,
0.08719364254,
0.08496148754,
0.08806932954,
0.08570007054,
0.08535801454000001,
0.08660106054000001,
0.09155603654000001,
0.08635694654,
0.09241881954,
0.08574653354,
0.08636359054000001
]
},
{
"command": "pnpr@main",
"mean": 0.08912385996424244,
"stddev": 0.0037642351182108117,
"median": 0.08838837054000001,
"user": 0.020238134545454547,
"system": 0.011912354545454544,
"min": 0.08528949654000001,
"max": 0.10508863354,
"times": [
0.08565419554,
0.09025909154,
0.08784586054000001,
0.08933382054000001,
0.08993210754000001,
0.08669367454,
0.08546812254000001,
0.08770105554,
0.08535762054000001,
0.09155469454000001,
0.08669685454,
0.09122691354000001,
0.08649275254000001,
0.08794015354000001,
0.08554554054,
0.08603422554000001,
0.09210998854,
0.08974074254,
0.08639905154000001,
0.10508863354,
0.08909712254,
0.08528949654000001,
0.08657334154,
0.08670925154,
0.08723772454,
0.08968092254000001,
0.09005327754,
0.09066704154,
0.09352656654000001,
0.09195280654000001,
0.09235066254,
0.08838837054000001,
0.09248569454000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.594311962040001,
"stddev": 0.15888070567492585,
"median": 4.58754017834,
"user": 1.8499221999999995,
"system": 1.38008268,
"min": 4.43953429834,
"max": 4.88104201234,
"times": [
4.6649287073400005,
4.61973706734,
4.88104201234,
4.6015455023400005,
4.445364194340001,
4.454707899340001,
4.8190858293400005,
4.443639255340001,
4.57353485434,
4.43953429834
]
},
{
"command": "pacquet@main",
"mean": 4.5333760424400005,
"stddev": 0.12356023612121941,
"median": 4.4969376293400005,
"user": 1.8352484,
"system": 1.41124328,
"min": 4.41752295634,
"max": 4.8170391963400006,
"times": [
4.41752295634,
4.45035695434,
4.6217135993400005,
4.515174362340001,
4.47870089634,
4.8170391963400006,
4.54410536334,
4.61547768534,
4.43839062534,
4.43527878534
]
},
{
"command": "pnpr@HEAD",
"mean": 3.4952662891400004,
"stddev": 0.04533260016592008,
"median": 3.48962005134,
"user": 1.2971318999999997,
"system": 1.2121191800000002,
"min": 3.44515409134,
"max": 3.56973553034,
"times": [
3.49434467734,
3.5231490973399997,
3.44515409134,
3.45281899434,
3.49278948734,
3.46556195034,
3.56973553034,
3.45486598734,
3.48645061534,
3.56779246034
]
},
{
"command": "pnpr@main",
"mean": 3.51342820064,
"stddev": 0.10227107090613913,
"median": 3.48164943384,
"user": 1.2837621000000001,
"system": 1.22355048,
"min": 3.44771025734,
"max": 3.76542848734,
"times": [
3.44771025734,
3.46743343634,
3.44792604434,
3.49663910434,
3.44818788034,
3.45071936934,
3.49678404034,
3.49586543134,
3.61758795534,
3.76542848734
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13306 |
| 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,519.61 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 285.14 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 283.32 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.19 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,352.50 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,445.15 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 254.63 ms |
… the root slot Review follow-ups on the root-slot skip: - Skipping the link was not enough on a repeat install. An install that predates this rule, or one where the version had lost the slot, leaves a link in the project; left in place it keeps shadowing the root copy, which is the duplicate the skip exists to remove. The pruner reclaims the real directories the graph walk creates, but not the links this pass used to create, so remove one here when it is in the way. A real directory stays the pruner's, and only ever belongs to a losing version. - Run the skip after link_path is built, so an alias that safe_join_modules_dir would reject still reports InvalidAlias instead of silently taking the skip. - Assert the nested copies are 2.0.0. The build-artifact checks alone also pass if a project links the built root 1.0.0 copy. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit d02654e |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Path::is_symlink only reports IO_REPARSE_TAG_SYMLINK, so the stale-entry cleanup missed every junction — and a junction is exactly what symlink_dir falls back to on Windows when it cannot create a true symlink. The duplicate the skip exists to remove therefore survived on the platform where the fallback is taken. A junction-aware predicate already existed, but only in pacquet-testing-utils, where production code cannot reach it. Move it to pacquet-fs beside its siblings remove_symlink_dir and read_symlink_dir, which already handle both reparse shapes, and let testing-utils delegate. That drops the duplicate copy along with the windows-only junction dependency testing-utils carried solely for it. A missing path is the common case here, and junction::exists reports it as an error rather than Ok(false), so NotFound reads as "nothing to clean up" while every other IO error propagates. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit cb1886e |
pnpm#13306) With nodeLinker=hoisted, every workspace project got a link to each of its direct dependencies, including the ones already materialized in the workspace-root node_modules. Node resolution walks up from the project, so that second entry is redundant — and it is a second copy for the build pass to run lifecycle scripts in. pnpm nests a copy only for the versions that lost the root slot. Upstream's map comes from the hoisting hierarchy, so a dependency the hoister moved to the root is simply absent from the importer's entry; pacquet derives it from the importer's lockfile declarations, which keeps the winner in the map, so the link pass has to recognize and skip it. The workspace root itself is exempt: it owns the hoisted slot, and its entries are the real directories rather than links to them. Two tests asserted the old shape and now pin the upstream rule, and the known-failure stub registered for this divergence (hoisted_workspace_duplicate_materialization) becomes a real assertion in run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker. Refs pnpm#13167
… suite (#13355) `just known-failures` piped into `rg`, which exits 1 on no matches, so an empty expected-failure list reported as a recipe failure. The workspace build now runs on its own un-silenced line, so a compile failure still aborts with cargo's diagnostics, and only the listing line tolerates a nonzero status, through just's `-` line prefix. The CLI end-to-end tests build as one target, so a stub lists as `<module>::known_failures::<name>` and the `^known_failures::` anchor never matched it. The pattern now matches the segment at any depth. TEST_PORTING.md pointed at a hoisted-layout stub that #13306 replaced with real assertions; the entry now names that test. --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
With
nodeLinker: hoisted, pacquet gave every workspace project a link to each of its direct dependencies — including the ones already materialized in the workspace-rootnode_modules. Node resolution walks up from the project, so that entry is redundant, and it is a second copy for the build pass to run lifecycle scripts in.pnpm nests a copy only for the versions that lost the root slot. Upstream's per-importer map is derived from the hoisting hierarchy, so a dependency the hoister moved to the root is simply absent from the importer's entry (
lockfileToHoistedDepGraph.ts→directDepsMap(Object.keys(nextHierarchy), graph)); pacquet derives the same map from the importer's lockfile declarations, which keeps the winner in it, so the link pass has to recognize and skip it.The workspace root is exempt — it owns the hoisted slot, and its entries are the real directories rather than links to them.
Behavior
Upstream's fixture for this is
run pre/postinstall scripts in a workspace that uses node-linker=hoisted(installing/deps-installer/test/install/lifecycleScripts.ts:718): four projects, two on@1and two on@2, asserting that the projects on the root-slot version have no nested copy while the other two do.node_modules/<pkg>(v1, root-slot winner)@1— won the slot)@2— lost the slot)Tests
This closes the known failure registered for exactly this divergence:
known_failures::hoisted_workspace_layout_does_not_duplicate_root_versioninhoisted_node_linker.rs, whose stub reason wasThe stub is gone and the assertion is now real, inside
run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker— the sibling test that was already carrying the fixture and had a comment explaining why it could not assert this yet. That leaveshoisted_node_linker.rswith noknown_failuresmodule at all.One other test asserted the old shape:
install_filters.rs::filtered_hoisted_install_materializes_full_shared_graph_but_links_only_selected_projectsexpected the selected project to nest a dependency that the same test also asserts is hoisted to the root. It now asserts the absence, for the same reason.Full suite green (7003 tests), clippy and dylint clean.
Note on the tracker
Picked up from #13167, whose description is well out of date — it lists 34 unchecked plan items and 39
allow_known_failure!sites; the real numbers onmainwere 9 (7 of them deliberate "do not port" entries) and 2. Details in this comment. After this PR one stub remains,importer_level_link_closure_divergence, which is blocked on a cross-stack decision rather than on code.Refs #13167
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.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit