Skip to content

fix(package-manager): run the pnpm:devPreinstall hook - #13403

Merged
zkochan merged 6 commits into
mainfrom
fix-13313
Jul 26, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix-13313

Conversation

@zkochan

@zkochan zkochan commented Jul 26, 2026 •

Copy link
Copy Markdown
Member

Summary

pacquet never ran the root project's pnpm:devPreinstall script — there was no implementation of the hook anywhere in pnpm/crates. The hook exists so a workspace can prepare state that resolution or linking then consumes: vercel/next.js uses it to generate a placeholder next bin, 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:context and before the lockfile is touched — including before the frozen path's freshness check. That is where pnpm runs it, at the top of mutateModules' _install.

Each gate was checked by running the same fixture through this build and through [email protected] side by side:

case pnpm 11 pacquet before pacquet after
install, --frozen-lockfile, add, update runs never runs runs
repeat install ("Already up to date") skips — skips
--ignore-scripts skips — skips
--lockfile-only, --dry-run skips — skips
fetch, rebuild skips — skips
a non-root member's own hook never runs — never runs

--lockfile-only and --dry-run were the non-obvious pair: pnpm reaches that outcome indirectly, because lockfileOnly forces ignoreScripts and --dry-run sets lockfileOnly. 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 optimistic preferFrozenLockfile path settles which delegation happens later, so a static predicate in _install would skip the hook outright whenever it guessed wrong.

So the delegation says so explicitly. 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.

Both silent-failure modes are closed and tested:

  • 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 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 also kept out of every process the install spawns. build_env is the single funnel for lifecycle hooks and pnpm run / exec alike, 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 nested pnpm install started from a lifecycle script of a delegated install would treat its own root hook as already run.

Closes #13313

Squash Commit Body

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 pnpm/pnpm#13313

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

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

Summary by CodeRabbit

  • New Features

    • Added support for the workspace root’s pnpm:devPreinstall hook during installation.
    • Runs early—before dependency resolution and linking—and applies to frozen installs while only executing for the workspace root.
    • Ensures workspace-published bin artifacts are prepared before dependent shims are created.
  • Bug Fixes

    • Prevents incorrect linking to workspace artifacts when the pnpm:devPreinstall hook is skipped or doesn’t complete as expected.
  • Documentation / Tests

    • Updated hook ordering guidance and expanded tests to verify exact run/skip conditions (e.g., --ignore-scripts, --lockfile-only).

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
Copilot AI review requested due to automatic review settings July 26, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Rust install pipeline now runs the workspace root’s pnpm:devPreinstall hook before dependency resolution and linking. It adds lifecycle wiring, delegation-marker isolation, shared environment helpers, tests, porting notes, and release metadata.

Changes

Root devPreinstall lifecycle

Layer / File(s) Summary
Lifecycle stage contract
pnpm/crates/executor/src/lifecycle.rs, pnpm/crates/executor/src/lib.rs
Defines and exports the pnpm:devPreinstall stage, runner wrapper, and delegation marker.
Install-time hook orchestration
pnpm/crates/package-manager/src/install.rs, pnpm11/installing/commands/src/runPacquet.ts
Runs the root hook before resolution and linking, applies eligibility checks, shares lifecycle environment helpers, and prevents duplicate execution across delegations.
Delegation environment isolation
pnpm/crates/executor/src/make_env.rs, pnpm/crates/executor/src/make_env/tests.rs, pnpm11/installing/commands/test/runPacquet.ts
Removes inherited delegation markers from lifecycle scripts and verifies marker behavior for resolving and non-resolving delegations.
Behavioral validation and release metadata
pnpm/crates/cli/tests/lifecycle_scripts.rs, pnpm/plans/TEST_PORTING.md, .changeset/run-the-dev-preinstall-hook.md
Covers ordering, frozen installs, suppression flags, root-only execution, pre-link bin preparation, and records the port and patch release.

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
Loading

Assessment against linked issues

Objective Addressed Explanation
Run the root pnpm:devPreinstall hook during installs before resolution and linking [#13313] ✅
Suppress the hook for --ignore-scripts and resolve-only operations [#13313] ✅
Execute the hook for the workspace root, including frozen installs, while preparing files before linking [#13313] ✅

Possibly related PRs

  • pnpm/pnpm#13030 — Both modify install-time lifecycle wiring in pnpm/crates/package-manager/src/install.rs.
  • pnpm/pnpm#13171 — Both modify install-time lifecycle execution and workspace bin linking.
  • pnpm/pnpm#13398 — Both modify project lifecycle execution flow in pnpm/crates/package-manager/src/install.rs.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13313

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

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Run root pnpm:devPreinstall hook at the start of installs

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Run root pnpm:devPreinstall once per install before resolution/linking and lockfile checks.
• Match pnpm’s skip conditions (ignore-scripts, lockfile-only/dry-run, rebuild,
 ignore-manifest-check).
• Add coverage proving ordering, workspace-bin preparation, and root-only semantics.
Diagram

graph TD
  A["pacquet CLI"] --> B["package-manager install"] --> C["run devPreinstall"] --> D["resolve + link"] --> E[("pnpm-lock.yaml")]
  C --> F[("root package.json")]
  C --> G["executor lifecycle"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add an explicit delegation marker to suppress duplicate hook runs
  • ➕ Avoids double-running pnpm:devPreinstall when another layer already ran it (e.g., delegated installs).
  • ➕ Makes behavior safer for non-idempotent hooks.
  • ➖ Requires coordinating a stable flag/env contract across stacks (risk of private protocol drift).
  • ➖ Adds another cross-layer behavior surface to maintain and document.
2. Centralize devPreinstall in the top-level command dispatcher only
  • ➕ Single source of truth for when the hook runs; fewer subtle gate mismatches.
  • ➕ Keeps install core focused on install mechanics, not command-layer semantics.
  • ➖ Harder to guarantee correct ordering relative to lockfile freshness checks without duplicating internal sequencing knowledge.
  • ➖ May miss programmatic entry points that bypass the dispatcher.
3. Persist a per-install sentinel (e.g., in-memory or temp file) to ensure once-only semantics
  • ➕ Prevents re-entry within the same install invocation even if multiple codepaths call into install.
  • ➕ Does not require cross-process env/flag coordination if scoped appropriately.
  • ➖ Sentinel scoping is tricky (process-wide vs workspace vs lockfile-dir); wrong scope can suppress legitimate runs.
  • ➖ Adds statefulness and potential edge cases in concurrent/multi-workspace scenarios.

Recommendation: The current approach (run root-only devPreinstall inside the install pipeline, before lockfile interaction) is the most robust way to guarantee ordering relative to resolution/linking. If duplicate execution in delegated flows becomes a practical problem, prefer an explicit, documented marker (flag/env) over re-encoding dispatch predicates inside install.rs, but only if maintainers are comfortable with the cross-layer contract.

Files changed (6) +336 / -23

Bug fix (3) +119 / -23
lib.rsExport devPreinstall hook API from executor crate +3/-2

Export devPreinstall hook API from executor crate

• Re-exports the new devPreinstall stage constant and 'run_dev_preinstall_hook' so the package-manager can invoke it consistently with other lifecycle helpers.

pnpm/crates/executor/src/lib.rs

lifecycle.rsIntroduce DEV_PREINSTALL_STAGE and runner for root hook +16/-2

Introduce DEV_PREINSTALL_STAGE and runner for root hook

• Defines 'DEV_PREINSTALL_STAGE' ('pnpm:devPreinstall') and adds 'run_dev_preinstall_hook()' implemented via the shared lifecycle stage runner. Updates documentation/comments to reflect that this hook runs before resolution and cannot assume 'node_modules' exists.

pnpm/crates/executor/src/lifecycle.rs

install.rsRun root pnpm:devPreinstall before lockfile freshness and install stages +100/-19

Run root pnpm:devPreinstall before lockfile freshness and install stages

• Invokes the root 'pnpm:devPreinstall' hook immediately after emitting context and before any lockfile freshness checks or writes, matching pnpm’s ordering. Adds explicit gating to skip the hook for ignore-scripts, resolve-only/lockfile-only/dry-run, rebuild, and ignore-manifest-check flows; refactors lifecycle env/path setup into helpers and ensures devPreinstall uses the pre-link env (no package-map option).

pnpm/crates/package-manager/src/install.rs

Tests (1) +211 / -0
lifecycle_scripts.rsAdd end-to-end lifecycle tests for root pnpm:devPreinstall +211/-0

Add end-to-end lifecycle tests for root pnpm:devPreinstall

• Introduces a new 'project_scripts::dev_preinstall' test module verifying execution order, frozen-install behavior, skip gates ('--ignore-scripts', '--lockfile-only'), and root-only semantics. Includes a workspace fixture proving the hook can create a bin target before linking occurs.

pnpm/crates/cli/tests/lifecycle_scripts.rs

Documentation (2) +6 / -0
run-the-dev-preinstall-hook.mdDocument devPreinstall hook behavior change in changeset +5/-0

Document devPreinstall hook behavior change in changeset

• Adds a changeset noting that the root 'pnpm:devPreinstall' script now runs at the start of installs (unless scripts are ignored). Explains the practical impact for workspaces (e.g., next.js placeholder bin generation) and links the motivating issue.

.changeset/run-the-dev-preinstall-hook.md

TEST_PORTING.mdRecord ported coverage for pnpm:devPreinstall behavior +1/-0

Record ported coverage for pnpm:devPreinstall behavior

• Updates the test porting plan to note that the TypeScript lifecycleScripts coverage now includes 'pnpm:devPreinstall', and that the port uncovered and fixed the missing implementation.

pnpm/plans/TEST_PORTING.md

@greptile-apps

greptile-apps Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The configured-shell failure in the new hook path should be fixed before merging because valid pnpm:devPreinstall scripts can execute under the wrong shell.

The delegation double-run and nested-marker issues are fixed, but run_dev_preinstall still passes no configured script shell, causing hooks that rely on scriptShell syntax or behavior to fail under the platform default.

Files Needing Attention: pnpm/crates/package-manager/src/install.rs

Reviews (6): Last reviewed commit: "perf(executor): refuse the delegation ma..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.0±0.03ms    33.9 MB/sec    1.05     11.6±0.03ms    32.3 MB/sec
packument/parse                1.00     37.9±0.50µs  1750.3 MB/sec    1.06     40.3±0.10µs  1647.7 MB/sec
tarball/download_dependency    1.00      2.3±0.07ms  1923.4 KB/sec    1.00      2.3±0.07ms  1919.7 KB/sec

@qodo-code-review

qodo-code-review Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Marker leaks via casing ✓ Resolved 🐞 Bug ☼ Reliability
Description
makePacquetEnv() removes PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN only with a case-sensitive key
match, so a differently-cased inherited variable can survive into the pacquet child. On Windows
(case-insensitive env lookups), that can make pacquet incorrectly skip pnpm:devPreinstall on
delegations where it must run.
Code

pnpm11/installing/commands/src/runPacquet.ts[R219-227]

+export function makePacquetEnv (opts: MakeRunPacquetOpts, callOpts?: RunPacquetCallOpts): NodeJS.ProcessEnv {
  const env = { ...process.env }
  for (const key of Object.keys(env)) {
    if (key.toLowerCase() === 'pnpm_config_virtual_store_dir_max_length') {
      delete env[key]
    }
+    if (key === DEV_PREINSTALL_ALREADY_RAN_ENV) {
+      delete env[key]
+    }
Relevance

⭐⭐⭐ High

Windows env/case issue can cause wrong hook skipping; reliability fixes (esp. Windows-specific) are
typically accepted.

PR-#13306

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The TS side scrubs the marker with a case-sensitive comparison, while the Rust side checks the
marker via std::env::var, which is case-insensitive on Windows, so any differently-cased inherited
marker can still suppress the hook.

pnpm11/installing/commands/src/runPacquet.ts[219-233]
pnpm/crates/package-manager/src/install.rs[3734-3757]

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

## Issue description
`makePacquetEnv()` deletes the `PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN` marker only when the key matches exactly. On Windows, environment variable lookup is case-insensitive, so an inherited marker with different casing can still be observed by pacquet and suppress `pnpm:devPreinstall` unexpectedly.

## Issue Context
This marker is intended as an internal handshake and is explicitly being scrubbed from non-resolve delegations; case-sensitive scrubbing defeats that goal on Windows.

## Fix Focus Areas
- pnpm11/installing/commands/src/runPacquet.ts[219-233]
- pnpm/crates/package-manager/src/install.rs[3734-3757]
- pnpm11/installing/commands/test/runPacquet.ts[59-91]

## Suggested fix
1. In `makePacquetEnv`, delete the marker using a case-insensitive comparison, e.g.:
  - `if (key.toLowerCase() === DEV_PREINSTALL_ALREADY_RAN_ENV.toLowerCase()) delete env[key]`
  or
  - collect keys and delete those where `key.localeCompare(DEV_PREINSTALL_ALREADY_RAN_ENV, undefined, { sensitivity: 'accent' }) === 0` is not sufficient; use explicit ASCII lowercasing.
2. Add a regression test that sets `process.env.pnpm_internal_dev_preinstall_already_ran = 'true'` (lowercased key) and asserts `makePacquetEnv(envOpts)[DEV_PREINSTALL_ALREADY_RAN_ENV]` is `undefined` for non-resolve delegations.

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



Remediation recommended

2. Case-variant marker can leak ✓ Resolved 📘 Rule violation ≡ Correctness
Description
build_env() removes PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN only by exact key match after
merging extraEnv, so a differently-cased key can still reach lifecycle scripts (especially on
Windows where env keys are case-insensitive). This breaks the intended private “handshake” contract
and can cause nested installs spawned by scripts to incorrectly treat pnpm:devPreinstall as
already run, enabling unsupported/user-controlled suppression of the hook.
Code

pnpm/crates/executor/src/make_env.rs[R122-125]

+    // Dropped after `extra_env` as well as from the parent env, so the
+    // scoping holds however the value arrived — a user `extraEnv` that
+    // names the marker cannot hand it to a script either.
+    env.remove(DEV_PREINSTALL_ALREADY_RAN_ENV);
Relevance

⭐⭐⭐ High

Team has accepted Windows env-key hardening; case-insensitive marker stripping aligns with precedent
around env collisions/leaks.

PR-#12943

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
In build_env(), the environment is constructed by merging opts.extra_env into env and then
calling env.remove(DEV_PREINSTALL_ALREADY_RAN_ENV), but HashMap::remove() only drops the
exact-cased key, so any case-variant injected via extraEnv remains present. The same area
documents Windows’ case-insensitive environment-variable semantics, and install.rs relies on
build_env ensuring this marker never reaches spawned processes so nested installs still run their
own pnpm:devPreinstall; however, the current behavior (and the new test covering only the
canonical spelling) leaves a case-variant leak untested and possible.

Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/executor/src/make_env.rs[115-126]
pnpm/crates/executor/src/make_env/tests.rs[308-312]
pnpm/crates/executor/src/make_env.rs[107-126]
pnpm/crates/executor/src/make_env.rs[154-196]
pnpm/crates/package-manager/src/install.rs[3734-3744]
pnpm/crates/executor/src/make_env/tests.rs[299-319]

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

## Issue description
`build_env()` strips `DEV_PREINSTALL_ALREADY_RAN_ENV` using `HashMap::remove()`, which is case-sensitive, after merging `extraEnv`. This allows a user to inject a differently-cased copy of the marker into lifecycle script environments; on Windows, where environment variable names are effectively case-insensitive, that leaked marker can be observed by nested installs spawned by scripts and cause them to incorrectly skip `pnpm:devPreinstall`, undermining the intended private, non-user-settable handshake.

## Issue Context
The marker is intended to be a private handshake scoped to a single delegated install, and comments/documentation (including in `install.rs`) assume that user-provided `extraEnv` cannot pass the marker through to scripts. With only exact-cased removal, that assumption is not reliable on Windows (and case-variant keys remain untested), which can lead to unsupported behavior where users effectively suppress the hook for nested installs.

## Fix Focus Areas
- pnpm/crates/executor/src/make_env.rs[122-126]
- pnpm/crates/package-manager/src/install.rs[3740-3744]
- pnpm/crates/executor/src/make_env/tests.rs[308-311]

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


3. Marker leaks via extraEnv ✓ Resolved 🐞 Bug ☼ Reliability
Description
build_env() drops PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN only from the inherited parent
environment, but then merges opts.extra_env without filtering, so config.extraEnv can
reintroduce the marker into lifecycle script environments. This can cause nested installs started by
lifecycle scripts to incorrectly treat pnpm:devPreinstall as already run, contradicting the
documented scoping behavior.
Code

pnpm/crates/executor/src/make_env.rs[R163-170]

+/// Whether `key` must be dropped from the inherited parent env: an
+/// `npm_package_*` stamp, a `(npm|pnpm)_config_*` auth credential, a
+/// per-call stamp [`build_env`] re-derives (`NODE`, `TMPDIR`,
+/// `INIT_CWD`, `PNPM_SCRIPT_SRC_DIR`), or
+/// [`DEV_PREINSTALL_ALREADY_RAN_ENV`]. Stripping the auth credentials
+/// keeps them out of dependency lifecycle scripts; stripping the
+/// delegation marker keeps it scoped to the install that received it,
+/// so a nested install started by a script still runs its own hook.
Relevance

⭐⭐⭐ High

Repo precedent: reserved env vars must not be overridable via extraEnv; likely filter this marker
too.

PR-#12943

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
is_stamping_key() now treats the marker as a dropped key, so it is removed from the inherited
parent env. However, build_env() later applies opts.extra_env verbatim, and config.extra_env
is the source of that map for lifecycle scripts—so a configured extraEnv entry can reintroduce the
marker into script environments. The current test only covers stripping from parent_env, leaving
this reintroduction path untested.

pnpm/crates/executor/src/make_env.rs[57-117]
pnpm/crates/executor/src/make_env.rs[159-191]
pnpm/crates/executor/src/lifecycle.rs[131-146]
pnpm/crates/package-manager/src/install.rs[3703-3711]
pnpm/crates/executor/src/make_env/tests.rs[299-316]

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

### Issue description
`DEV_PREINSTALL_ALREADY_RAN_ENV` is removed from the inherited parent env via `filter_parent_env()`/`is_stamping_key()`, but it can be re-added via `opts.extra_env` (which is fed from user-configurable `config.extra_env`). This breaks the intended scoping guarantee that the marker never reaches scripts.

### Issue Context
The marker is intended as a private, single-install handshake for delegated installs and should not propagate to lifecycle scripts (or anything they spawn). Current tests only validate stripping from `parent_env`, not from `extra_env`.

### Fix Focus Areas
- pnpm/crates/executor/src/make_env.rs[57-147]
- pnpm/crates/executor/src/make_env.rs[159-191]
- pnpm/crates/executor/src/make_env/tests.rs[299-316]

### What to change
- Ensure the final built env cannot contain `DEV_PREINSTALL_ALREADY_RAN_ENV` regardless of source:
 - Option A (simplest): after applying `opts.extra_env`, explicitly remove the marker key from `env`.
 - On Windows, remove case-insensitively (e.g., `retain(|k, _| !k.eq_ignore_ascii_case(DEV_PREINSTALL_ALREADY_RAN_ENV))`) to match the rest of the Windows env-key semantics.
 - Option B: when iterating `opts.extra_env`, skip inserts whose key matches the marker (case-insensitive on Windows).
- Add a regression test that sets the marker in `extra_env` (and a differently cased key for the Windows branch) and asserts it is absent from `built.env`.

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


4. Misleading DEV_PREINSTALL inheritance comment ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The comment claims the PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN marker causes a nested `pnpm
install` to skip its own hook, but the TypeScript delegator explicitly strips this env var for
non-resolve delegations. This comment does not accurately describe the current behavior and can
mislead future changes around hook deduplication.
Code

pnpm/crates/package-manager/src/install.rs[R3752-3754]

+/// The marker is inherited by anything the install spawns, so a nested
+/// `pnpm install` started from a lifecycle script during a delegated
+/// install sees it too and skips its own hook.
Relevance

⭐⭐⭐ High

Inaccurate/misleading comment; repo accepts tightening docs/comments to prevent drift.

PR-#13256

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust comment asserts the marker affects nested pnpm install executions, but the TypeScript
code deletes PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN from the spawned pacquet environment unless
explicitly set for resolve mode, and the test suite pins the non-leak behavior. This means the
comment does not reflect the actual current behavior of the delegation mechanism.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/install.rs[3752-3756]
pnpm11/installing/commands/src/runPacquet.ts[219-232]
pnpm11/installing/commands/test/runPacquet.ts[77-84]

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

## Issue description
A comment in `dev_preinstall_already_ran()` states that the delegation marker is inherited such that a nested `pnpm install` will see it and skip its own hook. However, the TypeScript delegator (`makePacquetEnv`) explicitly deletes this env var unless it is intentionally set for resolve-mode delegation, and tests assert it does not leak.

## Issue Context
This is an internal cross-stack handshake; incorrect documentation here can cause future maintainers to make incorrect assumptions about which processes see/propagate the marker.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install.rs[3752-3754]

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


View more (3)
5. Historical note in TEST_PORTING ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The added TEST_PORTING entry includes historical phrasing (`The port found ... unimplemented; it now
runs ...`) rather than describing the current behavior directly. This can quickly become stale and
violates the rule against historical implementation commentary in-line.
Code

pnpm/plans/TEST_PORTING.md[236]

+- [x] `TypeScript repo: installing/deps-installer/test/install/lifecycleScripts.ts:139` `run install scripts in the current project` covers the root project's own stages plus `pnpm:devPreinstall` — ported as the `project_scripts` and `project_scripts::dev_preinstall` modules in `crates/cli/tests/lifecycle_scripts.rs`. The port found `pnpm:devPreinstall` unimplemented; it now runs before resolution and linking.
Relevance

⭐⭐⭐ High

Repo reviewers commonly request removing historical/temporal phrasing from docs/comments in plans
and tests.

PR-#13343
PR-#13386

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance ID 772199 forbids newly added/modified comments from describing historical
implementations. The added line explicitly references what the port previously lacked ("found ...
unimplemented"), which is historical context rather than current behavior description.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/plans/TEST_PORTING.md[236-236]

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

## Issue description
A newly added documentation line uses historical phrasing about what the port previously lacked.

## Issue Context
The sentence says the port "found" `pnpm:devPreinstall` unimplemented, which is history rather than current behavior.

## Fix Focus Areas
- pnpm/plans/TEST_PORTING.md[236-236]

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


6. Extra work on filtered installs 🐞 Bug ➹ Performance
Description
When the workspace root is absent from project_manifests, root_defines_hook defaults to true and
run_dev_preinstall() is called even if the root has no pnpm:devPreinstall script. This triggers an
unnecessary manifest read and an unconditional env::vars() snapshot inside the executor before
discovering there is no script to run.
Code

pnpm/crates/package-manager/src/install.rs[R1305-1316]

+            let root_defines_hook = project_manifests
+                .iter()
+                .find(|(project_dir, _)| {
+                    pacquet_fs::lexical_normalize(project_dir)
+                        == pacquet_fs::lexical_normalize(&workspace_root)
+                })
+                .is_none_or(|(_, manifest)| {
+                    matches!(manifest.script(DEV_PREINSTALL_STAGE, true), Ok(Some(_)))
+                });
+            if root_defines_hook {
+                run_dev_preinstall::<Reporter>(config, &workspace_root)?;
+            }
Relevance

⭐⭐ Medium

Perf-only; similar “defer work” suggestions were sometimes rejected as premature optimization.

PR-#13151
PR-#13173
PR-#13398

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new is_none_or(...) fallback makes the filtered-install (root not in-memory) path always
invoke run_dev_preinstall(). The executor implementation snapshots env::vars() before checking
whether the stage script exists, so invoking it in the no-script case does extra work.

pnpm/crates/package-manager/src/install.rs[1278-1316]
pnpm/crates/executor/src/lifecycle.rs[173-210]

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

## Issue description
In the `project_manifests`-missing (filtered install) case, the code always calls `run_dev_preinstall()`, which forces the executor path to read `package.json` and snapshot the full environment even when the root has no `pnpm:devPreinstall` script.

## Issue Context
The fallback is correct for roots omitted from `project_manifests`, but it can still cheaply check whether the script exists before invoking the lifecycle runner (which snapshots env unconditionally).

## Fix Focus Areas
- pnpm/crates/package-manager/src/install.rs[1305-1316]
- pnpm/crates/executor/src/lifecycle.rs[173-218]

## Suggested fix
Option A (localized, low-risk):
- When `project_manifests` does not include `workspace_root`, do a lightweight manifest check first (e.g. `pacquet_package_manifest::safe_read_package_json_from_dir(&workspace_root)` and inspect `scripts["pnpm:devPreinstall"]`), and only call `run_dev_preinstall()` if the script is present.

Option B (broader perf win):
- Refactor `run_lifecycle_stages()` to delay `env::vars().collect()` until after at least one target stage’s script is found, so “script absent” doesn’t pay the env snapshot cost.

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


7. Unneeded env snapshot work ✓ Resolved 🐞 Bug ➹ Performance
Description
Install::run now invokes the pnpm:devPreinstall lifecycle path on most installs, and
run_lifecycle_stages() eagerly collects env::vars() even when the target script is not present.
This adds avoidable per-install overhead (extra work even for repos that do not define
pnpm:devPreinstall) on a core hot path.
Code

pnpm/crates/package-manager/src/install.rs[R1292-1294]

+        if !config.ignore_scripts && !resolve_only && !ignore_manifest_check && rebuild.is_none() {
+            run_dev_preinstall::<Reporter>(config, &workspace_root)?;
+        }
Relevance

⭐⭐ Medium

Perf micro-optimizations are sometimes accepted, but no close precedent for lazy env snapshotting in
lifecycle runner.

PR-#13375
PR-#13288

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The installer now calls run_dev_preinstall() for most non-suppressed installs; that calls into the
executor’s lifecycle runner. The executor’s shared run_lifecycle_stages() collects the full
environment unconditionally before iterating stages, so even when the hook is missing the env
snapshot work still happens.

pnpm/crates/package-manager/src/install.rs[1278-1294]
pnpm/crates/executor/src/lifecycle.rs[173-220]

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

### Issue description
`run_lifecycle_stages()` snapshots the full parent environment (`env::vars().collect()`) before it knows whether any of the requested stages will actually run. With this PR, the install path calls the dev-preinstall wrapper on most installs, so repos that *don’t* define `pnpm:devPreinstall` still pay the environment snapshot cost every time.

### Issue Context
The `pnpm:devPreinstall` hook is called once per install (when scripts aren’t suppressed), and `run_dev_preinstall_hook()` uses `run_lifecycle_stages()`.

### Fix Focus Areas
- pnpm/crates/executor/src/lifecycle.rs[173-220]
- pnpm/crates/package-manager/src/install.rs[1278-1294]

### Suggested fix
In `run_lifecycle_stages()`, compute whether any stage would run *before* collecting `parent_env`:
- Inspect `scripts` for the requested stage names (and preserve the special `install`-stage fallback logic, including the `binding.gyp` existence check).
- If none of the requested stages will run, return `Ok(false)` early.
- Only then perform `env::vars().collect()` and proceed to spawn the hook(s).

This keeps behavior identical while removing unnecessary work when `pnpm:devPreinstall` is not defined.

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



Informational

8. Avoidable env retain scan ✓ Resolved 🐞 Bug ➹ Performance ⭐ New
Description
build_env() now calls env.retain() to remove PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN, which
linearly scans the entire env map after it has been inflated with npm_package_* stamps. Since
build_env() is executed per lifecycle stage/script, this adds avoidable work on a core install hot
path.
Code

pnpm/crates/executor/src/make_env.rs[R122-127]

+    // Dropped after `extra_env` as well as from the parent env, so the
+    // scoping holds however the value arrived — a user `extraEnv` that
+    // names the marker cannot hand it to a script either. Spelled the
+    // same way [`is_stamping_key`] matches it, so the two agree on
+    // Windows, where a differently-cased entry is the same variable.
+    env.retain(|key, _| !is_dev_preinstall_marker(key, cfg!(windows)));
Relevance

⭐⭐⭐ High

Team often accepts hot-path micro-optimizations (avoid repeated scans/compiles); likely to replace
retain with O(1) removal.

PR-#13375
PR-#13368
PR-#13398

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new env.retain(...) runs after npm_package_* stamping and after merging extra_env, so it
scans a potentially large env map each time build_env() is called. build_env() is invoked for
each lifecycle stage that runs, via run_lifecycle_hook() inside the per-stage loop in
run_lifecycle_stages().

pnpm/crates/executor/src/make_env.rs[57-75]
pnpm/crates/executor/src/make_env.rs[107-128]
pnpm/crates/executor/src/lifecycle.rs[190-234]
pnpm/crates/executor/src/lifecycle.rs[274-288]

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

### Issue description
`build_env()` currently removes `PNPM_INTERNAL_DEV_PREINSTALL_ALREADY_RAN` by running `env.retain(...)` over the entire environment map. This adds an extra full-map scan for every lifecycle script env build.

### Issue Context
- The marker is already removed from the inherited parent env via `filter_parent_env()`/`is_stamping_key()`.
- The only remaining reintroduction vector is `opts.extra_env`.

### Fix Focus Areas
- pnpm/crates/executor/src/make_env.rs[107-129]

### Suggested fix
- When iterating `opts.extra_env`, skip inserting entries whose key matches `DEV_PREINSTALL_ALREADY_RAN_ENV` (using the same Windows casing rule as `is_dev_preinstall_marker`).
- Remove the subsequent `env.retain(|key, _| !is_dev_preinstall_marker(...))` pass, since the marker can no longer enter the map via `extra_env` and is already stripped from the parent env.

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


9. Changeset missing pnpm entry ✓ Resolved 📘 Rule violation § Compliance
Description
The new changeset declares a bump for pacquet but does not include the required pnpm package
entry in its front-matter. This can cause the release tooling to miss or misclassify the
user-visible behavior change in the pnpm-published package.
Code

.changeset/run-the-dev-preinstall-hook.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Analogous “add pnpm entry to pacquet-only changeset” suggestions were repeatedly rejected in recent
PRs.

PR-#13349
PR-#12991
PR-#13386

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance ID 713436 requires each new/modified changeset to include a pnpm package entry with a
valid bump type. The added changeset front-matter only includes "pacquet": patch and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/run-the-dev-preinstall-hook.md[1-3]

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

## Issue description
The new changeset file does not list the `pnpm` package in its front-matter, which violates the repo requirement to explicitly declare the `pnpm` bump.

## Issue Context
File `.changeset/run-the-dev-preinstall-hook.md` currently contains only `"pacquet": patch`.

## Fix Focus Areas
- .changeset/run-the-dev-preinstall-hook.md[1-3]

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


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pnpm/crates/cli/tests/lifecycle_scripts.rs (2)

1789-1998: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add 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() in install.rs also gate --dry-run, pacquet fetch, and pacquet 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 win

Log 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

📥 Commits

Reviewing files that changed from the base of the PR and between b9df82e and ccfe324.

📒 Files selected for processing (6)
  • .changeset/run-the-dev-preinstall-hook.md
  • pnpm/crates/cli/tests/lifecycle_scripts.rs
  • pnpm/crates/executor/src/lib.rs
  • pnpm/crates/executor/src/lifecycle.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/plans/TEST_PORTING.md

@codecov-commenter

codecov-commenter commented Jul 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.55%. Comparing base (b9df82e) to head (aa3ea84).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: aa3ea840df97

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.468 ± 0.141 2.355 2.778 1.66 ± 0.18
pacquet@main 2.506 ± 0.160 2.342 2.761 1.68 ± 0.19
pnpr@HEAD 1.580 ± 0.161 1.352 1.765 1.06 ± 0.15
pnpr@main 1.491 ± 0.137 1.340 1.772 1.00
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 261.4 ± 9.8 248.7 280.0 1.01 ± 0.05
pacquet@main 259.2 ± 8.7 249.5 274.2 1.00
pnpr@HEAD 268.7 ± 6.8 255.9 276.6 1.04 ± 0.04
pnpr@main 273.5 ± 5.8 264.6 282.5 1.06 ± 0.04
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.768 ± 0.020 2.732 2.793 1.75 ± 0.18
pacquet@main 2.755 ± 0.021 2.706 2.779 1.74 ± 0.17
pnpr@HEAD 1.583 ± 0.158 1.424 1.859 1.00
pnpr@main 1.606 ± 0.144 1.417 1.847 1.01 ± 0.14
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 593.0 ± 10.5 569.3 607.9 1.97 ± 0.06
pacquet@main 584.5 ± 9.9 574.6 609.5 1.94 ± 0.06
pnpr@HEAD 304.4 ± 2.2 301.2 307.0 1.01 ± 0.02
pnpr@main 300.9 ± 6.9 290.0 310.7 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.911 ± 0.012 1.893 1.933 6.39 ± 0.12
pacquet@main 1.907 ± 0.011 1.885 1.922 6.38 ± 0.12
pnpr@HEAD 0.304 ± 0.008 0.293 0.318 1.02 ± 0.03
pnpr@main 0.299 ± 0.005 0.291 0.308 1.00
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 359.0 ± 8.1 349.3 372.7 4.16 ± 0.14
pacquet@main 364.2 ± 13.9 349.5 396.3 4.22 ± 0.19
pnpr@HEAD 87.3 ± 1.6 84.2 90.6 1.01 ± 0.03
pnpr@main 86.4 ± 2.0 82.6 90.0 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.624 ± 0.159 4.441 4.813 1.32 ± 0.06
pacquet@main 4.595 ± 0.151 4.430 4.834 1.31 ± 0.06
pnpr@HEAD 3.540 ± 0.103 3.458 3.803 1.01 ± 0.04
pnpr@main 3.509 ± 0.107 3.442 3.772 1.00
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
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13403
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,731.54 ms
(-0.19%)Baseline: 2,736.76 ms
3,284.11 ms
(83.17%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,893.35 ms
(+0.07%)Baseline: 1,892.12 ms
2,270.54 ms
(83.39%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
569.35 ms
(-1.12%)Baseline: 575.77 ms
690.92 ms
(82.40%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
349.33 ms
(-0.50%)Baseline: 351.08 ms
421.29 ms
(82.92%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,354.82 ms
(-0.11%)Baseline: 2,357.40 ms
2,828.88 ms
(83.24%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,440.59 ms
(+0.40%)Baseline: 4,423.05 ms
5,307.66 ms
(83.66%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
248.71 ms
(+0.71%)Baseline: 246.95 ms
296.34 ms
(83.93%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13403
Testbedpnpr

⚠️ 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-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,423.90 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
292.74 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
301.22 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.24 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,352.41 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,458.46 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
255.90 ms
🐰 View full continuous benchmarking report in Bencher

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.
Copilot AI review requested due to automatic review settings July 26, 2026 20:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between ccfe324 and db2c079.

📒 Files selected for processing (6)
  • .changeset/run-the-dev-preinstall-hook.md
  • pnpm/crates/cli/tests/lifecycle_scripts.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/plans/TEST_PORTING.md
  • pnpm11/installing/commands/src/runPacquet.ts
  • pnpm11/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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit db2c079

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

…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.
Copilot AI review requested due to automatic review settings July 26, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
pnpm11/installing/commands/src/runPacquet.ts (1)

209-213: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the frozen-install lifecycle contract in this comment.

--ignore-manifest-check only bypasses pacquet’s manifest freshness check; it does not suppress pnpm: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

📥 Commits

Reviewing files that changed from the base of the PR and between db2c079 and b8c2687.

📒 Files selected for processing (7)
  • pnpm/crates/executor/src/lib.rs
  • pnpm/crates/executor/src/lifecycle.rs
  • pnpm/crates/executor/src/make_env.rs
  • pnpm/crates/executor/src/make_env/tests.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm11/installing/commands/src/runPacquet.ts
  • pnpm11/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

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12 never runs the pnpm:devPreinstall lifecycle hook

3 participants