Repository navigation
fix(bins): hold back missing bins in the hoisted linker's nested .bin - #15563
Conversation
The hoisted linker links every `node_modules/.bin` while it imports the tree, before builds run. A dependency nested under another package also has that package's `node_modules/.bin` on PATH during its lifecycle scripts, so a shim of a bin its preinstall has yet to create shadowed the command there, as it did in a project's `.bin` before #15511. Nothing linked those nested directories again after the builds, so they could not simply hold the bins back. Both stacks now hold back missing-target bins in nested directories too, record the directories that held something back, and link them again once the builds ran. A bin whose target is still missing then gets its dependent shim, so the result matches the previous behavior, minus the shim on PATH during the build. In pnpm 11 `linkBins` reports such directories through a new `heldBackBinsDirs` option, `linkHoistedModules` returns them, and the headless install relinks them after `buildModules`. In pnpm 12 `link_bins_of_packages_cached` returns whether it held a bin back, `link_hoisted_modules` returns the directories, and `run_build_phase` relinks them. Adds `@pnpm.e2e/[email protected]` and `@pnpm.e2e/nests-own-bin-created-by-preinstall`, which nests 1.0.0 under the hoisted linker, and an e2e per stack. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (21)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe Rust and TypeScript hoisted linkers now report directories where bins were held back because targets are missing. Install build phases retain those directories and link their dependency bins after build processing. Tests cover the linker behavior and nested preinstall-created binaries. ChangesHeld-back bin relinking
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant link_hoisted_modules
participant LinkPhaseOutput
participant run_build_phase
participant link_held_back_bins
link_hoisted_modules->>LinkPhaseOutput: held-back bin directories
LinkPhaseOutput->>run_build_phase: held_back_bins_dirs
run_build_phase->>run_build_phase: process dependency builds
run_build_phase->>link_held_back_bins: link bins after build processing
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The reviewed install paths relink deferred bins after dependency builds. No issue requiring a pre-merge fix was established. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
pnpm11/bins/linker/src/index.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. pnpm11/bins/linker/test/index.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency). pnpm11/installing/deps-restorer/src/index.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency).
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 |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15563 +/- ##
=======================================
Coverage 91.80% 91.80%
=======================================
Files 1427 1427
Lines 192704 192755 +51
=======================================
+ Hits 176917 176967 +50
- Misses 15787 15788 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.99537147278,
"stddev": 0.11142008639555889,
"median": 2.97665005638,
"user": 2.97587874,
"system": 2.4570804799999992,
"min": 2.8347885913799997,
"max": 3.21017202138
},
{
"command": "pacquet@main",
"mean": 2.79885465578,
"stddev": 0.15499645053397795,
"median": 2.83396000738,
"user": 2.7800571400000003,
"system": 2.2743852799999997,
"min": 2.51571083638,
"max": 3.02756804738
},
{
"command": "pnpr@HEAD",
"mean": 1.5193998046800001,
"stddev": 0.13466405736418674,
"median": 1.49451790588,
"user": 1.71002774,
"system": 1.6382372800000002,
"min": 1.36807272838,
"max": 1.70747574738
},
{
"command": "pnpr@main",
"mean": 1.5077464135800003,
"stddev": 0.10659396832501387,
"median": 1.5128469773800002,
"user": 1.7371572399999997,
"system": 1.64497118,
"min": 1.35434123038,
"max": 1.65623997638
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26052572002,
"stddev": 0.012870920978060774,
"median": 0.26210038722,
"user": 0.29792752,
"system": 0.60608842,
"min": 0.24138307022000002,
"max": 0.28041789922000004
},
{
"command": "pacquet@main",
"mean": 0.25206522082,
"stddev": 0.019435521531377575,
"median": 0.24651169072,
"user": 0.26914942,
"system": 0.60071702,
"min": 0.22712722022,
"max": 0.28687321922000003
},
{
"command": "pnpr@HEAD",
"mean": 0.30990091062,
"stddev": 0.05601337724063494,
"median": 0.29116008672000004,
"user": 0.32397631999999993,
"system": 0.6652249200000001,
"min": 0.25299175522,
"max": 0.45339397822000005
},
{
"command": "pnpr@main",
"mean": 0.31889484382000005,
"stddev": 0.036110174340821824,
"median": 0.31847406922000004,
"user": 0.33584522,
"system": 0.66056152,
"min": 0.26161843422000003,
"max": 0.39772161222
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.010454824144549768,
"stddev": 0.0019434982795738776,
"median": 0.0103853335,
"user": 0.006147420473933644,
"system": 0.004978316398104266,
"min": 0.007098334500000001,
"max": 0.0163394855
},
{
"command": "pacquet@main",
"mean": 0.013959267946601933,
"stddev": 0.004208546049200363,
"median": 0.013371075,
"user": 0.008144539417475727,
"system": 0.006636957475728157,
"min": 0.006827366500000001,
"max": 0.0307917455
},
{
"command": "pnpr@HEAD",
"mean": 0.015433222136363632,
"stddev": 0.0033203473089167064,
"median": 0.0147453595,
"user": 0.008648241590909088,
"system": 0.0076685100000000025,
"min": 0.0104848995,
"max": 0.028280225500000002
},
{
"command": "pnpr@main",
"mean": 0.014573933121951222,
"stddev": 0.0032382448589543607,
"median": 0.014080785000000002,
"user": 0.008622491544715448,
"system": 0.006826440813008128,
"min": 0.0099641735,
"max": 0.025781296500000002
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.014451420683870968,
"stddev": 0.006032261470163156,
"median": 0.0125921238,
"user": 0.007266491225806449,
"system": 0.008009307612903227,
"min": 0.007900666800000001,
"max": 0.0446466058
},
{
"command": "pacquet@main",
"mean": 0.013271761204040403,
"stddev": 0.002851548504837084,
"median": 0.0129477858,
"user": 0.007107814343434343,
"system": 0.0069638154545454585,
"min": 0.0078840618,
"max": 0.021624252800000004
},
{
"command": "pnpr@HEAD",
"mean": 0.011608462866115709,
"stddev": 0.0025715783871800182,
"median": 0.0111507933,
"user": 0.00647469818181818,
"system": 0.005854533553719007,
"min": 0.007526486800000001,
"max": 0.018862212800000003
},
{
"command": "pnpr@main",
"mean": 0.013590701067857147,
"stddev": 0.0030204091974647008,
"median": 0.0129934143,
"user": 0.006238490833333334,
"system": 0.008119173928571427,
"min": 0.008708306800000001,
"max": 0.021415131800000004
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.91536748362,
"stddev": 0.0634567133315992,
"median": 2.90188094262,
"user": 2.9883244199999996,
"system": 2.5315403400000003,
"min": 2.8341873986199997,
"max": 3.07072788462
},
{
"command": "pacquet@main",
"mean": 2.8227673862200002,
"stddev": 0.06561181468277177,
"median": 2.81727521812,
"user": 2.7454780199999997,
"system": 2.3645273399999995,
"min": 2.72950536362,
"max": 2.93813877562
},
{
"command": "pnpr@HEAD",
"mean": 1.6587777560199999,
"stddev": 0.13444165786247536,
"median": 1.65262601412,
"user": 1.6699401200000001,
"system": 1.8268740400000003,
"min": 1.4969868176199999,
"max": 1.86203774562
},
{
"command": "pnpr@main",
"mean": 1.6557621064199999,
"stddev": 0.14125117951236837,
"median": 1.59744914562,
"user": 1.6042955200000002,
"system": 1.8158718400000002,
"min": 1.5064917756199998,
"max": 1.87962187962
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5954247477600001,
"stddev": 0.07202718594480387,
"median": 0.5796210794600001,
"user": 0.86067932,
"system": 0.8990924799999999,
"min": 0.51091853046,
"max": 0.7223324654600001
},
{
"command": "pacquet@main",
"mean": 0.5346023711599999,
"stddev": 0.060570118919034695,
"median": 0.54520194846,
"user": 0.7652450199999998,
"system": 0.8278118799999999,
"min": 0.45016167946,
"max": 0.63662340246
},
{
"command": "pnpr@HEAD",
"mean": 0.32571634575999997,
"stddev": 0.02043985685793263,
"median": 0.32591664146,
"user": 0.26902061999999993,
"system": 0.57623088,
"min": 0.28825011146,
"max": 0.36463906346
},
{
"command": "pnpr@main",
"mean": 0.3980547763600001,
"stddev": 0.05952596419002698,
"median": 0.38758759696,
"user": 0.3375316199999999,
"system": 0.69481068,
"min": 0.33865897146,
"max": 0.48330069546000004
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8730010628200002,
"stddev": 0.13476837270405334,
"median": 1.85800014822,
"user": 1.28274534,
"system": 1.14149388,
"min": 1.70988069472,
"max": 2.0518344667200004
},
{
"command": "pacquet@main",
"mean": 1.71963461062,
"stddev": 0.08300101278053909,
"median": 1.69535266872,
"user": 0.9959588399999999,
"system": 0.88072948,
"min": 1.6468859007199999,
"max": 1.93624174072
},
{
"command": "pnpr@HEAD",
"mean": 0.31159915022000007,
"stddev": 0.030299879197736825,
"median": 0.29818986672000003,
"user": 0.25708724,
"system": 0.56076758,
"min": 0.27877997472,
"max": 0.37547915072
},
{
"command": "pnpr@main",
"mean": 0.40836061012,
"stddev": 0.09082472201645768,
"median": 0.37187098422,
"user": 0.34586453999999994,
"system": 0.7167085799999999,
"min": 0.31103975372,
"max": 0.5613650707200001
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.58632001308,
"stddev": 0.11393421886183426,
"median": 0.53625888198,
"user": 0.5865399,
"system": 0.1929699,
"min": 0.48734948448000004,
"max": 0.8047813744800001
},
{
"command": "pacquet@main",
"mean": 0.51133538568,
"stddev": 0.07670066055317296,
"median": 0.49623074948,
"user": 0.5305978,
"system": 0.16627139999999999,
"min": 0.39932800248,
"max": 0.65794333248
},
{
"command": "pnpr@HEAD",
"mean": 0.13686566248000004,
"stddev": 0.025754237555137248,
"median": 0.12721682648000002,
"user": 0.06989465714285714,
"system": 0.026379342857142857,
"min": 0.11230271048,
"max": 0.20419444548000001
},
{
"command": "pnpr@main",
"mean": 0.12410005326260871,
"stddev": 0.014844700683603215,
"median": 0.12231769448,
"user": 0.0569603652173913,
"system": 0.026108678260869562,
"min": 0.10605134848,
"max": 0.15763225148
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.8951649573422222,
"stddev": 0.09547869745027374,
"median": 0.8856992621200002,
"user": 0.937677671111111,
"system": 0.20877238000000004,
"min": 0.7708909531200001,
"max": 1.0701467331199999
},
{
"command": "pacquet@main",
"mean": 0.9993604107866667,
"stddev": 0.2028603820987724,
"median": 1.05451803312,
"user": 1.0448760044444443,
"system": 0.22861826888888886,
"min": 0.6239138921200001,
"max": 1.24769794112
},
{
"command": "pnpm@HEAD",
"mean": 4.127619569231111,
"stddev": 0.44296472604256987,
"median": 3.89128135812,
"user": 6.366152448888889,
"system": 0.3269441577777778,
"min": 3.78245952512,
"max": 5.05389635012
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18937733378000002,
"stddev": 0.010238451946990891,
"median": 0.18776427398,
"user": 0.14926302666666666,
"system": 0.08408313333333334,
"min": 0.17589841298,
"max": 0.21436625298
},
{
"command": "pacquet@main",
"mean": 0.19739021358,
"stddev": 0.00532046676444642,
"median": 0.19715036798,
"user": 0.15006062666666667,
"system": 0.09760106666666668,
"min": 0.18769597798,
"max": 0.20407742198
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.8966752385,
"stddev": 0.4252330245607307,
"median": 4.7473558553999995,
"user": 2.41676368,
"system": 1.95713844,
"min": 4.5542238394,
"max": 6.0202529324
},
{
"command": "pacquet@main",
"mean": 4.5541917738999995,
"stddev": 0.08931943631532609,
"median": 4.5250292994,
"user": 2.0609455799999994,
"system": 1.7408729400000003,
"min": 4.4500886844,
"max": 4.6880671774
},
{
"command": "pnpr@HEAD",
"mean": 3.5360893763999997,
"stddev": 0.08698743456398483,
"median": 3.5236616419000004,
"user": 1.61547888,
"system": 1.57241834,
"min": 3.4070703414000003,
"max": 3.6927770594
},
{
"command": "pnpr@main",
"mean": 3.6092724159,
"stddev": 0.16738536870187545,
"median": 3.6159232639,
"user": 1.60462688,
"system": 1.57493004,
"min": 3.3902495784,
"max": 3.8456817694
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18450978583142857,
"stddev": 0.021405084503536682,
"median": 0.17826817376000004,
"user": 0.2250311857142857,
"system": 0.16880804285714285,
"min": 0.15551384226,
"max": 0.22496389226000002
},
{
"command": "pacquet@main",
"mean": 0.22540570184333333,
"stddev": 0.05947747209036149,
"median": 0.20118075876000002,
"user": 0.2705999,
"system": 0.17465831666666665,
"min": 0.16309360526000002,
"max": 0.36726679126
},
{
"command": "pnpr@HEAD",
"mean": 0.22877498726,
"stddev": 0.0430898446386717,
"median": 0.23177945026000002,
"user": 0.2562861692307693,
"system": 0.19415597692307693,
"min": 0.15296600926,
"max": 0.30665958726
},
{
"command": "pnpr@main",
"mean": 0.24816822453272727,
"stddev": 0.042708097679792195,
"median": 0.24258266626000002,
"user": 0.2993532181818182,
"system": 0.16313735454545453,
"min": 0.20213309126,
"max": 0.33093002126
}
]
} |
PR Summary by QodoHold back nested hoisted bins until dependency builds complete
AI Description
Diagram
High-Level Assessment
Files changed (20)
|
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
The hoisted linker's bundled-dependency pass linked a bundling package's `node_modules/.bin` with the ordinary linker, so a bundled bin whose target was missing got its shim before builds and was never recorded for the post-build relink. pnpm 11's hoisted pass scans the whole directory, so it already held such bins back. The bundled pass now marks its packages build pending, links them through the reporting linker, and returns the directories that held a bin back, with the bundled package names, for the build phase to link again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Qodo's finding Builds still see missing bin shims is valid. Fixed in 7d73e2c. The hoisted linker's bundled-dependency pass now works like the graph pass: it marks bundled packages build pending, links them through Written by an agent (Claude Code, claude-opus-5-5). |
Thanks for the confirmation. Finding 1 appears addressed by |
|
Code review by qodo was updated up to the latest commit 7d73e2c |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…pnpm#15563) Under nodeLinker: hoisted, a dependency nested in another package's node_modules has that package's node_modules/.bin on PATH during its lifecycle scripts. The hoisted linker links every nested .bin while it imports the tree, before builds, and never again, so a nested dependency whose preinstall creates its own bin found a shim of the missing file on PATH. pnpm#15511 held such bins back only in a project's .bin, which the post-build relink covers. Both stacks now hold back missing-target bins in nested .bin directories too, record the directories that held something back, and link those again after the builds. A bin whose target is still missing then gets its dependent shim, so the result matches the previous one, minus the shim on PATH during the build. Only recorded directories are relinked. pnpm 11: linkBins reports such directories through a heldBackBinsDirs option, linkHoistedModules returns them, and the headless install relinks them after buildModules. pnpm 12: link_bins_of_packages_cached returns whether it held a bin back, link_hoisted_modules returns the directories, and they reach run_build_phase through the link phase output.
Summary
Follow-up to #15511, which listed this gap as a known limit.
Under
nodeLinker: hoisted, a dependency nested in another package'snode_modulesruns its lifecycle scripts with that package'snode_modules/.binon PATH. The hoisted linker links every nested.binbefore builds run and never again. So a nested dependency whose preinstall creates its own bin (thenodepackage's pattern, #15501) found a shim of the missing file on PATH. #15511 fixed this for the project's.binonly, because the post-build relink covers project.bindirectories and nothing covered the nested ones.Both stacks now:
.bindirectories as well.Only the recorded directories are relinked, so a warm hoisted install with no missing targets does no extra work.
Changes:
pnpm11/bins/linker: aheldBackBinsDirsoption collects the.bindirectories that held a bin back.pnpm11/installing/deps-restorer:linkHoistedModulesholds back missing-target bins at every level (the flag is renamed toholdBackMissingBins) and returns the nested directories. The headless install relinks them afterbuildModules.pnpm/crates/cmd-shim:link_bins_of_packages_cachedreturns whether it held a bin back.pnpm/crates/deps-restorer:link_hoisted_modulesreturns the nested directories,HoistedLinkerOutputandLinkPhaseOutputcarry them, andrun_build_phaserelinks them before the project.binpass.pnpr/.fixtures:@pnpm.e2e/[email protected], and@pnpm.e2e/[email protected], which depends on 1.0.0. With 2.0.0 at the root, the hoisted linker nests 1.0.0 under it.No changeset: #15511 has not been released. Its pending pnpm 12 changeset ("pnpm install no longer puts a dependency's bin on PATH for that dependency's own lifecycle scripts before the bin's file exists") already describes this. In pnpm 11 the nested exposure came from #15511 itself, because cmd-shim used to throw on a missing target.
Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
pnpm changeset) if this PR changes any publishedpackage. Not needed: this completes the unreleased fix(bins): link a dependency's bin before its target exists #15511, whose pending changeset covers it.
Verification
own_bin_is_not_on_path_before_preinstall_creates_it_when_nested_by_hoisted_linkerfailed before the change, with the shim innests-own-bin-created-by-preinstall/node_modules/.bin. It passes now.pnpm-cmd-shim,pnpm-deps-restorer, and the CLI lifecycle-script, bin, hoist, allow-build, rebuild and patch suites. Clippy and dylint are clean.@pnpm/bins.linkertests: 44 passed..cmdand.ps1shims there.Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
PATHbefore they exist.