Repository navigation
Conversation
pacquet never ran the root project's `pnpm:devPreinstall` script. The
hook exists so a workspace can prepare state that resolution or linking
consumes: vercel/next.js uses it to generate a placeholder `next` bin,
and without it every dependent's shim was linked against a file that no
step of the install ever created.
Run it once per install from the lockfile directory, for the root
project only, right after `pnpm:context` and before the lockfile is
touched — including before the frozen path's freshness check, matching
where pnpm runs it at the top of `mutateModules`' `_install`.
The gates were each checked against pnpm 11.17.0 on the same fixture:
- `--ignore-scripts` skips it, as it does every other project script.
- `--lockfile-only` and `--dry-run` skip it. pnpm reaches the same
outcome indirectly: `lockfileOnly` forces `ignoreScripts`, and
`--dry-run` sets `lockfileOnly`.
- A repeat "Already up to date" install skips it in both stacks — the
optimistic short-circuit returns before pnpm's `_install` and before
this call site.
- A rebuild skips it: `pnpm rebuild` never enters `mutateModules`.
- `ignore_manifest_check` skips it, covering both `pacquet fetch`
(pnpm's `ignorePackageManifest`) and the TypeScript CLI delegating a
frozen materialization, which already ran the hook itself before
handing the install over.
One duplicate remains: the TypeScript CLI's resolve-mode delegation
(`runPacquet.run({ resolve: true })`) drops both injected flags, so it
runs the hook and pacquet then runs it again. Every way to suppress it
was worse than the symptom — restating a ten-clause delegation
predicate in `_install`, where it would drift, or inventing a private
env-var marker — and the hook is idempotent by contract.
The env setup shared with the project-script path is split in two:
`pnpm:devPreinstall` takes the plain `extraEnv` + `nodeOptions`, without
the `.package-map.json` `NODE_OPTIONS` entry, because pnpm adds that one
only once it links and builds and the file does not exist yet when the
hook runs.
Closes #13313
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe Rust install pipeline now runs the workspace root’s ChangesRoot devPreinstall lifecycle
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Install as Install::run_inner
participant Hook as run_dev_preinstall
participant Runner as run_dev_preinstall_hook
participant Linking as ResolutionAndLinking
Install->>Hook: execute eligible root hook
Hook->>Runner: run pnpm:devPreinstall
Runner-->>Hook: return lifecycle result
Install->>Linking: continue resolution and linking
Assessment against linked issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 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 QodoRun root pnpm:devPreinstall hook at the start of installs
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Confidence Score: 4/5The configured-shell failure in the new hook path should be fixed before merging because valid The delegation double-run and nested-marker issues are fixed, but Files Needing Attention: pnpm/crates/package-manager/src/install.rs Reviews (6): Last reviewed commit: "perf(executor): refuse the delegation ma..." | Re-trigger Greptile |
Micro-Benchmark ResultsLinux |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pnpm/crates/cli/tests/lifecycle_scripts.rs (2)
1789-1998: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the remaining skip conditions (
--dry-run,fetch,rebuild).This module tests two of the five documented skip flags (
--ignore-scripts,--lockfile-only).resolve_only/ignore_manifest_check/rebuild.is_none()ininstall.rsalso gate--dry-run,pacquet fetch, andpacquet rebuild, but none of those paths have a dedicated regression test here.🤖 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/cli/tests/lifecycle_scripts.rs` around lines 1789 - 1998, Add dedicated tests in the dev_preinstall module for each remaining skip condition: install with --dry-run, the pacquet fetch command, and pacquet rebuild. Follow the existing is_skipped_under_ignore_scripts and is_skipped_by_lockfile_only patterns, asserting success and that order.txt is not created, using project_with_dev_preinstall and the appropriate command arguments.
1828-1830: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLog rendered values before ordering
assert_eq!s.Per
pnpm/CODE_STYLE_GUIDE.md, lifecycle-ordering assertions comparing non-scalar values should log the rendered value first so a CI failure shows the actual order without re-running locally.🧪 Example
let order = fs::read_to_string(workspace.join("order.txt")).expect("read order.txt"); let stages: Vec<&str> = order.lines().collect(); + eprintln!("ORDER:\n{stages:?}\n"); assert_eq!(stages, EXPECTED_ORDER);Also applies to: 1854-1856, 1990-1990
🤖 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/cli/tests/lifecycle_scripts.rs` around lines 1828 - 1830, Before each lifecycle-ordering assert_eq! comparing rendered or collection values—including the assertions near stages and the additional locations noted—log the actual value in its rendered form using the repository’s established test logging pattern, then retain the existing expected-value assertions unchanged.Source: Path instructions
🤖 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 @.changeset/run-the-dev-preinstall-hook.md:
- Line 5: Update the release note to state that the pnpm:devPreinstall hook runs
before resolution and linking only when scripts are enabled and the operation is
not --lockfile-only, --dry-run, fetch, or rebuild; preserve the existing
workspace-preparation example and issue reference.
---
Nitpick comments:
In `@pnpm/crates/cli/tests/lifecycle_scripts.rs`:
- Around line 1789-1998: Add dedicated tests in the dev_preinstall module for
each remaining skip condition: install with --dry-run, the pacquet fetch
command, and pacquet rebuild. Follow the existing
is_skipped_under_ignore_scripts and is_skipped_by_lockfile_only patterns,
asserting success and that order.txt is not created, using
project_with_dev_preinstall and the appropriate command arguments.
- Around line 1828-1830: Before each lifecycle-ordering assert_eq! comparing
rendered or collection values—including the assertions near stages and the
additional locations noted—log the actual value in its rendered form using the
repository’s established test logging pattern, then retain the existing
expected-value assertions unchanged.
🪄 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: a2795b94-5cad-434b-ad06-759c83be88cf
📒 Files selected for processing (6)
.changeset/run-the-dev-preinstall-hook.mdpnpm/crates/cli/tests/lifecycle_scripts.rspnpm/crates/executor/src/lib.rspnpm/crates/executor/src/lifecycle.rspnpm/crates/package-manager/src/install.rspnpm/plans/TEST_PORTING.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13403 +/- ##
==========================================
+ Coverage 87.53% 87.55% +0.02%
==========================================
Files 542 544 +2
Lines 93294 93424 +130
==========================================
+ Hits 81665 81798 +133
+ Misses 11629 11626 -3 ☔ 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.4678286275400003,
"stddev": 0.14106575480645286,
"median": 2.42816609104,
"user": 1.4872318199999999,
"system": 1.27918256,
"min": 2.35481543054,
"max": 2.77833023754,
"times": [
2.42472451854,
2.35824993854,
2.43160766354,
2.46395226354,
2.65267961254,
2.77833023754,
2.4802098525400003,
2.35481543054,
2.36497545254,
2.36874130554
]
},
{
"command": "pacquet@main",
"mean": 2.50617274114,
"stddev": 0.1597102491326335,
"median": 2.4476510615400002,
"user": 1.5164310199999997,
"system": 1.2406665599999998,
"min": 2.34226807954,
"max": 2.76099919954,
"times": [
2.44734187954,
2.6183085735400002,
2.44796024354,
2.70610920354,
2.38014957454,
2.34226807954,
2.34259164854,
2.37436020354,
2.64163880554,
2.76099919954
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5798069211399999,
"stddev": 0.1614956729379441,
"median": 1.58031273654,
"user": 1.00899662,
"system": 1.1128769600000001,
"min": 1.35241245454,
"max": 1.7653788115400002,
"times": [
1.7653788115400002,
1.72167708954,
1.7557186095400001,
1.7231585855400002,
1.6287112965400001,
1.44228385754,
1.35241245454,
1.52018432254,
1.53191417654,
1.3566300075400002
]
},
{
"command": "pnpr@main",
"mean": 1.4910422469400002,
"stddev": 0.13659381926769149,
"median": 1.5048613770400001,
"user": 1.06307412,
"system": 1.10071826,
"min": 1.34022330754,
"max": 1.77198920354,
"times": [
1.38386983454,
1.53103627554,
1.3696910445400001,
1.61922940054,
1.53190922754,
1.48457110754,
1.34022330754,
1.35275142154,
1.77198920354,
1.5251516465400001
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26136781336000003,
"stddev": 0.009811317803105922,
"median": 0.25939627026000006,
"user": 0.20691168000000001,
"system": 0.5442805,
"min": 0.24870740476000003,
"max": 0.27998736076,
"times": [
0.26928003076000007,
0.27196333776000003,
0.25787389676000005,
0.26312685676,
0.25274245476000007,
0.26091864376000007,
0.25371682676000007,
0.25536132076000007,
0.24870740476000003,
0.27998736076
]
},
{
"command": "pacquet@main",
"mean": 0.2591984723600001,
"stddev": 0.008725716867831546,
"median": 0.2571462387600001,
"user": 0.20826178,
"system": 0.5317209999999999,
"min": 0.24953320876,
"max": 0.27415828676000004,
"times": [
0.25474600376000006,
0.25375974776000004,
0.25269474576000006,
0.25167299276000005,
0.25954647376000006,
0.24953320876,
0.27378439376,
0.26097744476000007,
0.26111142576,
0.27415828676000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26865829326000007,
"stddev": 0.0067892203927010725,
"median": 0.26976198226000003,
"user": 0.20931278000000003,
"system": 0.5170606999999998,
"min": 0.25590363076000006,
"max": 0.27664013376,
"times": [
0.27316635976000003,
0.26232695276000007,
0.26429913276000006,
0.26436046776000005,
0.26853091176000005,
0.25590363076000006,
0.27512736876000005,
0.27664013376,
0.27523492176000003,
0.27099305276
]
},
{
"command": "pnpr@main",
"mean": 0.27354669826000005,
"stddev": 0.005809955551406902,
"median": 0.27471935176000006,
"user": 0.22113098,
"system": 0.5314924000000001,
"min": 0.26460950576000003,
"max": 0.28245121476000007,
"times": [
0.26698696776,
0.27670456576,
0.26460950576000003,
0.27188844776000004,
0.26725267776000006,
0.27317985676000006,
0.27625884676000007,
0.27874014476000003,
0.27739475476000003,
0.28245121476000007
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7676451409399996,
"stddev": 0.019996689032447768,
"median": 2.7648509734399997,
"user": 1.7123786399999996,
"system": 1.2895951800000003,
"min": 2.73153966794,
"max": 2.79310452594,
"times": [
2.78062040394,
2.79204165594,
2.75942865494,
2.73153966794,
2.76191275594,
2.74494841894,
2.79310452594,
2.76241755694,
2.76728438994,
2.78315337894
]
},
{
"command": "pacquet@main",
"mean": 2.75478087474,
"stddev": 0.0205046497784799,
"median": 2.75854204344,
"user": 1.6824564399999997,
"system": 1.27377398,
"min": 2.70608020094,
"max": 2.77913137894,
"times": [
2.7503562589399997,
2.74607744394,
2.77176574494,
2.76562767994,
2.74412780194,
2.76755815094,
2.70608020094,
2.77913137894,
2.76106769394,
2.75601639294
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5833751882399998,
"stddev": 0.1584916721001088,
"median": 1.4993172639399999,
"user": 1.02913074,
"system": 1.1229182800000002,
"min": 1.42390334594,
"max": 1.85948712794,
"times": [
1.4836854979399998,
1.75002725994,
1.65036125194,
1.51494902994,
1.47042227194,
1.85948712794,
1.76430366094,
1.43895121894,
1.42390334594,
1.4776612169399999
]
},
{
"command": "pnpr@main",
"mean": 1.60644499824,
"stddev": 0.14374572870586483,
"median": 1.5716166589399998,
"user": 1.0348760399999999,
"system": 1.1133520799999999,
"min": 1.4165003219399999,
"max": 1.84659683294,
"times": [
1.7847051239399998,
1.84659683294,
1.5838652619399998,
1.5334492759399998,
1.53165789794,
1.5593680559399998,
1.64018345894,
1.4346478649399999,
1.4165003219399999,
1.73347588794
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5930339942,
"stddev": 0.010506482849703515,
"median": 0.5947055846,
"user": 0.71344472,
"system": 0.6759511600000001,
"min": 0.5693463361000001,
"max": 0.6078519011000001,
"times": [
0.5895403391,
0.5967560611,
0.5947450581,
0.5933463771,
0.6078519011000001,
0.5847186701,
0.5962605591000001,
0.6031085291,
0.5946661111,
0.5693463361000001
]
},
{
"command": "pacquet@main",
"mean": 0.5845314211000001,
"stddev": 0.009938577390896222,
"median": 0.5835507386000001,
"user": 0.7028714199999999,
"system": 0.6771193600000001,
"min": 0.5746132531,
"max": 0.6094838801000001,
"times": [
0.5746132531,
0.5838831391,
0.5824199271,
0.5867859681,
0.5832183381,
0.6094838801000001,
0.5760440241000001,
0.5849754341000001,
0.5878901151000001,
0.5760001321
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30438749970000006,
"stddev": 0.0021886338628935797,
"median": 0.30419859660000004,
"user": 0.19618111999999996,
"system": 0.5487963600000001,
"min": 0.30121900710000005,
"max": 0.30704887210000004,
"times": [
0.3029414771,
0.3019218301,
0.30299069910000004,
0.30656442110000004,
0.30704887210000004,
0.30304560310000006,
0.3059883271,
0.30121900710000005,
0.3053515901,
0.3068031701
]
},
{
"command": "pnpr@main",
"mean": 0.3008670767,
"stddev": 0.006883821382588253,
"median": 0.30069894410000003,
"user": 0.20220312,
"system": 0.5106900600000001,
"min": 0.2899598311,
"max": 0.31065145810000006,
"times": [
0.3053167251,
0.30095170410000005,
0.2899598311,
0.29338856010000003,
0.29919007210000004,
0.31010213610000004,
0.31065145810000006,
0.29469213110000003,
0.3004461841,
0.3039719651
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9111440985,
"stddev": 0.01238569926479263,
"median": 1.9123524482,
"user": 0.9367447,
"system": 0.7755331400000001,
"min": 1.8933463552,
"max": 1.9328185762,
"times": [
1.9127987532,
1.9061530332,
1.8977336782,
1.9271270112,
1.9121763822,
1.9158925222,
1.9328185762,
1.9008661592,
1.9125285142000001,
1.8933463552
]
},
{
"command": "pacquet@main",
"mean": 1.9066674768000003,
"stddev": 0.010725450894008018,
"median": 1.9081278272,
"user": 0.9277403,
"system": 0.77722894,
"min": 1.8847236582,
"max": 1.9221320572,
"times": [
1.9221320572,
1.9050619612000002,
1.9109366401999999,
1.9054952262,
1.9150422622,
1.8847236582,
1.8959104082,
1.9018067592,
1.9107604282,
1.9148053672
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30420592100000005,
"stddev": 0.00830283437385814,
"median": 0.3012431407,
"user": 0.1898228,
"system": 0.5331459399999999,
"min": 0.29273519820000005,
"max": 0.31832971820000006,
"times": [
0.3012497532,
0.31832971820000006,
0.29273519820000005,
0.29741000120000005,
0.30027887620000004,
0.29694238120000005,
0.31166175520000006,
0.3012365282,
0.31292408020000007,
0.30929091820000004
]
},
{
"command": "pnpr@main",
"mean": 0.2989008422,
"stddev": 0.005157073824620152,
"median": 0.29917492570000004,
"user": 0.21229399999999998,
"system": 0.49961964,
"min": 0.2907112922,
"max": 0.30789175520000006,
"times": [
0.2969998702,
0.29649189420000005,
0.30418615620000006,
0.29232717220000004,
0.30107800920000005,
0.30789175520000006,
0.2907112922,
0.29825099320000004,
0.30097242120000006,
0.30009885820000004
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35898540338,
"stddev": 0.008102582281798063,
"median": 0.35767900168,
"user": 0.35601762,
"system": 0.05465302,
"min": 0.34932736268,
"max": 0.37265385668,
"times": [
0.35300817668,
0.35459760668,
0.36076039668,
0.37265385668,
0.34932736268,
0.36735261468,
0.36605541568,
0.36296002368,
0.34971980168,
0.35341877868
]
},
{
"command": "pacquet@main",
"mean": 0.36418304748,
"stddev": 0.013908805461203724,
"median": 0.36150285818,
"user": 0.35656681999999995,
"system": 0.05731902,
"min": 0.34950944668,
"max": 0.39627156768,
"times": [
0.35366641468,
0.37444579668,
0.36021383868,
0.39627156768,
0.34950944668,
0.36029090368,
0.36987627268,
0.34957048068,
0.36271481268,
0.36527094068
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08728146989212124,
"stddev": 0.0016465447194802508,
"median": 0.08728413268,
"user": 0.022410210909090914,
"system": 0.00772003696969697,
"min": 0.08423744268000001,
"max": 0.09064923068000001,
"times": [
0.08656040168000001,
0.08534185968,
0.09039370168000001,
0.08456369568000001,
0.08599824368,
0.08834747268000001,
0.08721615468,
0.08925305668000001,
0.08798311768,
0.08541899468000001,
0.08682909668000001,
0.08828635768000001,
0.08840715568,
0.08490613968,
0.08918598968000001,
0.08565043068,
0.08709952568000001,
0.08728413268,
0.08796978268000001,
0.08557823468,
0.08423744268000001,
0.08731452968,
0.08758430768,
0.08831406068,
0.08559839168000001,
0.08767622968000001,
0.08713109568,
0.08848494168000001,
0.08644088668000001,
0.08747667468,
0.09064923068000001,
0.09038916268000001,
0.08671800768
]
},
{
"command": "pnpr@main",
"mean": 0.08638764697411765,
"stddev": 0.0020307133278575336,
"median": 0.08670630568000001,
"user": 0.020777502352941173,
"system": 0.008349465882352941,
"min": 0.08264077968000001,
"max": 0.08999675468000001,
"times": [
0.08368438168,
0.08999675468000001,
0.08516403468,
0.08922787868000001,
0.08545935168,
0.08645412168000001,
0.08289090068,
0.08331734168,
0.08636857068,
0.08478197668000001,
0.08691248368000001,
0.08595979268000001,
0.08724370668,
0.08703934268,
0.08264077968000001,
0.08275387268,
0.08742948568,
0.08746246868,
0.08735375368000001,
0.08965378968000001,
0.08479854868,
0.08785174968000001,
0.08649853568,
0.08874358868000001,
0.08694763968000001,
0.08748133268000001,
0.08818963468,
0.08754858968000001,
0.08650012768000001,
0.08934000068,
0.08767734268,
0.08413303568000001,
0.08577841068,
0.08389667168
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.6235980983800005,
"stddev": 0.15893002708456905,
"median": 4.61834598228,
"user": 1.6843069399999997,
"system": 1.33060232,
"min": 4.44059009628,
"max": 4.81278473628,
"times": [
4.74662235928,
4.49006960528,
4.47904760328,
4.78125182128,
4.47364194728,
4.44059009628,
4.48780808428,
4.81278473628,
4.76704925728,
4.75711547328
]
},
{
"command": "pacquet@main",
"mean": 4.59450199438,
"stddev": 0.15142330462613052,
"median": 4.57649957278,
"user": 1.67489684,
"system": 1.3178916199999997,
"min": 4.42985899228,
"max": 4.83379100528,
"times": [
4.54932332428,
4.45192484428,
4.46164755028,
4.83379100528,
4.79291689928,
4.60551203428,
4.46322498828,
4.42985899228,
4.75314448428,
4.60367582128
]
},
{
"command": "pnpr@HEAD",
"mean": 3.53950300578,
"stddev": 0.10290372831019731,
"median": 3.50011256128,
"user": 1.15503164,
"system": 1.24347392,
"min": 3.4584557292800002,
"max": 3.80319567228,
"times": [
3.46428249728,
3.5919731712800003,
3.5049336652800003,
3.47219223428,
3.80319567228,
3.49036733928,
3.56308227228,
3.5512560192800002,
3.4584557292800002,
3.49529145728
]
},
{
"command": "pnpr@main",
"mean": 3.5093210402799997,
"stddev": 0.10709832305052473,
"median": 3.46212636728,
"user": 1.1689497399999997,
"system": 1.19325362,
"min": 3.44241510828,
"max": 3.77185102528,
"times": [
3.4442157462800003,
3.44282054028,
3.47067761528,
3.44991733928,
3.45357511928,
3.51864981228,
3.61925242728,
3.77185102528,
3.44241510828,
3.47983566928
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13403 |
| 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,423.90 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 292.74 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 301.22 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.24 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,352.41 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,458.46 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 255.90 ms |
The TypeScript CLI runs the root project's `pnpm:devPreinstall` at the
top of `mutateModules`' `_install`, before it knows which install path
it will take. When it then hands the whole install to pacquet via
`runPacquet.run({ resolve: true })`, pacquet ran the hook a second time.
The frozen materialization was already covered: it is given
`--ignore-manifest-check`, which pacquet's gate treats as "the caller
already ran it". Resolve mode deliberately drops both injected flags and
carries nothing else pacquet could key off, and the decision cannot be
predicted at the point pnpm runs the hook — the optimistic
`preferFrozenLockfile` path settles which delegation happens later, so a
static predicate in `_install` would skip the hook outright whenever it
guessed wrong.
Pass an explicit marker instead. `makePacquetEnv` sets
`PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN=true` for resolve mode only,
and pacquet's gate reads it. The name sits outside `PNPM_CONFIG_*`
because it is a private handshake for the lifetime of one delegated
install, not a user-settable knob.
Two ways this could have failed silently, both closed:
- pacquet matches the exact string `true`, not merely "the variable is
set". An empty or `false` value runs the hook, so a stray assignment
cannot reintroduce the very bug the marker exists to prevent.
- pnpm strips any inherited value before deciding, so an ambient marker
cannot leak into a frozen delegation, where pnpm relies on pacquet not
having run the hook.
The marker is still inherited by processes the install spawns, so a
nested `pnpm install` started from a lifecycle script during a delegated
install skips its own hook; noted on the reader.
Also gate the pacquet-side call on the root manifest already in memory,
the way pnpm gates on `rootProjectManifest?.scripts?.[DEV_PREINSTALL]`.
An install whose root defines no hook no longer re-reads `package.json`
or snapshots the environment, and the executor's own read stays as the
fallback for a filtered install whose root is not among the importers.
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 `@pnpm11/installing/commands/src/runPacquet.ts`:
- Around line 205-216: Correct the lifecycle explanation in the comment above
the private handshake marker: state that only resolve mode uses the marker,
while frozen delegation must omit it so pacquet runs pnpm:devPreinstall itself;
do not claim --ignore-manifest-check suppresses the hook.
- Around line 225-226: Update the environment sanitization in runPacquet to
remove DEV_PREINSTALL_ALREADY_RAN_ENV regardless of key casing, including
lowercase and mixed-case variants. Extend the existing runPacquet environment
sanitizer test with regression cases covering those casing variants and verify
the marker is absent afterward.
🪄 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: 3cef842b-ac08-446c-973b-6d16ec0499ec
📒 Files selected for processing (6)
.changeset/run-the-dev-preinstall-hook.mdpnpm/crates/cli/tests/lifecycle_scripts.rspnpm/crates/package-manager/src/install.rspnpm/plans/TEST_PORTING.mdpnpm11/installing/commands/src/runPacquet.tspnpm11/installing/commands/test/runPacquet.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- .changeset/run-the-dev-preinstall-hook.md
- pnpm/crates/cli/tests/lifecycle_scripts.rs
- pnpm/plans/TEST_PORTING.md
- pnpm/crates/package-manager/src/install.rs
|
Code review by qodo was updated up to the latest commit db2c079 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…scripts Two ways the marker introduced for the delegated install could still suppress a hook that ought to run. A lifecycle script of a delegated install inherits the marker, so a nested `pnpm install` it starts would treat its own root project's `pnpm:devPreinstall` as already run. The marker describes the install that received it, not any install a script of that install may begin. `build_env` is where every spawn funnels through — lifecycle hooks and `pnpm run` / `exec` alike — and it already drops keys that must not propagate, such as the `(npm|pnpm)_config_*` auth credentials. Add the marker to that set, so no child process can see it. The constant moves to the executor crate, which owns script-environment construction; the package-manager imports it for its gate. Separately, `makePacquetEnv` stripped an inherited marker with a case-sensitive comparison. Windows env names are case-insensitive, so a differently-cased copy survived into the child and read as a delegation marker there. Compare case-insensitively, as the virtual-store key in the same loop already does. Also correct the comment on the marker: `--ignore-manifest-check` is what suppresses the hook on a frozen delegation, but only because pacquet's gate for this hook reads that flag as "the caller already ran it" — the flag does not name the hook itself.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
pnpm11/installing/commands/src/runPacquet.ts (1)
209-213: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winCorrect the frozen-install lifecycle contract in this comment.
--ignore-manifest-checkonly bypasses pacquet’s manifest freshness check; it does not suppresspnpm:devPreinstall. Frozen delegation must omit the marker so pacquet runs the hook itself. This repeats the previously reported issue, which has regressed here.Proposed correction
- * Only resolve mode needs it. A frozen materialization is given - * `--ignore-manifest-check`, which pacquet's own gate for this hook - * already reads as "the caller ran it" — so it is suppressed there - * without a marker. Pacquet invoked directly by a user has no earlier - * run to deduplicate against. + * Only resolve mode needs the marker. Frozen materialization + * deliberately omits it so pacquet runs `pnpm:devPreinstall` itself; + * `--ignore-manifest-check` only skips its manifest freshness check. + * Pacquet invoked directly by a user likewise has no earlier run to + * deduplicate against.As per path instructions, comments must document accurate non-obvious lifecycle contracts rather than misstate implementation behavior.
🤖 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/commands/src/runPacquet.ts` around lines 209 - 213, Correct the lifecycle explanation in the comment above the frozen materialization handling: state that --ignore-manifest-check only bypasses manifest freshness validation, while omitting the marker allows pacquet to run pnpm:devPreinstall itself. Remove the inaccurate claim that pacquet’s gate suppresses the hook.Source: Path instructions
🤖 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.
Duplicate comments:
In `@pnpm11/installing/commands/src/runPacquet.ts`:
- Around line 209-213: Correct the lifecycle explanation in the comment above
the frozen materialization handling: state that --ignore-manifest-check only
bypasses manifest freshness validation, while omitting the marker allows pacquet
to run pnpm:devPreinstall itself. Remove the inaccurate claim that pacquet’s
gate suppresses the hook.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 52ac6f73-0033-41e6-9285-f2460337aa69
📒 Files selected for processing (7)
pnpm/crates/executor/src/lib.rspnpm/crates/executor/src/lifecycle.rspnpm/crates/executor/src/make_env.rspnpm/crates/executor/src/make_env/tests.rspnpm/crates/package-manager/src/install.rspnpm11/installing/commands/src/runPacquet.tspnpm11/installing/commands/test/runPacquet.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm11/installing/commands/test/runPacquet.ts
- pnpm/crates/package-manager/src/install.rs
Summary
pacquet never ran the root project's
pnpm:devPreinstallscript — there was no implementation of the hook anywhere inpnpm/crates. The hook exists so a workspace can prepare state that resolution or linking then consumes: vercel/next.js uses it to generate a placeholdernextbin, and without it every dependent's shim was linked against a file no step of the install ever created, so invoking it produced a shell "No such file or directory" instead of the actionable message the placeholder prints.This runs it once per install from the lockfile directory, for the root project only, right after
pnpm:contextand before the lockfile is touched — including before the frozen path's freshness check. That is where pnpm runs it, at the top ofmutateModules'_install.Each gate was checked by running the same fixture through this build and through
[email protected]side by side:install,--frozen-lockfile,add,update--ignore-scripts--lockfile-only,--dry-runfetch,rebuild--lockfile-onlyand--dry-runwere the non-obvious pair: pnpm reaches that outcome indirectly, becauselockfileOnlyforcesignoreScriptsand--dry-runsetslockfileOnly. Running the two binaries side by side is what surfaced it — my first cut ran the hook in both cases.The resolve-mode delegation no longer double-runs it
When the TypeScript CLI hands a whole install to pacquet via
runPacquet.run({ resolve: true }), it has already run the hook itself. The frozen delegation was covered from the start — it is given--ignore-manifest-check, which pacquet's gate treats as "the caller already ran it" — but resolve mode drops both injected flags and carries nothing else to key off. The choice cannot be predicted where pnpm runs the hook either: the optimisticpreferFrozenLockfilepath settles which delegation happens later, so a static predicate in_installwould skip the hook outright whenever it guessed wrong.So the delegation says so explicitly.
makePacquetEnvsetsPNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN=truefor resolve mode only, and pacquet's gate reads it. The name sits outsidePNPM_CONFIG_*because it is a private handshake for the lifetime of one delegated install, not a user-settable knob.Both silent-failure modes are closed and tested:
true, not merely "the variable is set" — an empty orfalsevalue runs the hook, so a stray assignment cannot reintroduce the bug the marker exists to prevent.The marker is also kept out of every process the install spawns.
build_envis the single funnel for lifecycle hooks andpnpm run/execalike, and it already drops keys that must not propagate — the(npm|pnpm)_config_*auth credentials, the per-call stamps — so the marker joins that set. Without it a nestedpnpm installstarted from a lifecycle script of a delegated install would treat its own root hook as already run.Closes #13313
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).
Summary by CodeRabbit
New Features
pnpm:devPreinstallhook during installation.Bug Fixes
pnpm:devPreinstallhook is skipped or doesn’t complete as expected.Documentation / Tests
--ignore-scripts,--lockfile-only).