Skip to content

feat(pacquet): honor extraBinPaths and extraEnv from the updateConfig hook - #12943

Merged
zkochan merged 5 commits into
pnpm:mainfrom
TrevorBurnham:feat/pacquet-update-config-extra-bin-paths-env
Jul 13, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
TrevorBurnham:feat/pacquet-update-config-extra-bin-paths-env

Conversation

@TrevorBurnham

@TrevorBurnham TrevorBurnham commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The TypeScript pnpm CLI passes the entire Config object through the
updateConfig pnpmfile hook and adopts the returned object wholesale, so a hook
can read and extend extraBinPaths / extraEnv. Pacquet only round-tripped
WorkspaceSettings through the hook, silently dropping both fields — a hook that
set them was a no-op.

This brings pacquet to parity:

  • Adds extra_env to Config (extra_bin_paths already existed).
  • Seeds the updateConfig hook input with the live extraBinPaths / extraEnv
    so a hook can append to them, then reads the hook's values back from the delta
    and assigns them to Config. Neither is a pnpm-workspace.yaml key, so they
    are special-cased like storeDir / catalogs rather than going through
    WorkspaceSettings::apply_to.
  • Seeds config.extra_env into every child-process spawn site — the
    install-family lifecycle scripts (install, fresh/frozen lockfile installs),
    run, recursive run, pack, publish, exec, and the dlx bin. The
    lifecycle env builder (make_env.rs) applies extra_env before pnpm's
    reserved per-call stamps (INIT_CWD, PNPM_SCRIPT_SRC_DIR,
    npm_config_user_agent, the verify-deps guard), so pnpm's keys win on
    conflict while non-reserved extraEnv keys still apply — matching TS
    runLifecycleHook. The exec/dlx spawns apply it the same way.
  • Forwards config.extra_bin_paths to project (root) lifecycle scripts,
    matching TS install/index.ts.

Note on scope: config.extra_env is populated only by the updateConfig hook,
which today runs only for the install-family commands (install, deploy, dedupe,
prune). So it is non-empty only under those; the seedings at the other spawn
sites read an empty map until the hook broadens, but are wired uniformly so
behavior stays consistent when it does.

npmPath is intentionally not implemented: it is a type-only field on the
TypeScript Config that is never read as a value, and publish is native on
both stacks, so pacquet ignoring it already matches TypeScript behavior.

Squash Commit Body

feat(pacquet): honor extraBinPaths and extraEnv from the updateConfig hook

The TypeScript pnpm CLI passes the whole Config object through the
updateConfig pnpmfile hook and adopts the returned object wholesale, so
a hook can read and extend extraBinPaths / extraEnv. Pacquet only
round-tripped WorkspaceSettings through the hook, silently dropping both
fields.

Bring pacquet to parity:

- Add extra_env to Config (extra_bin_paths already existed).
- In run_update_config_hooks, seed the hook input with the live
  extraBinPaths / extraEnv (so a hook can append to them), then read the
  hook's values back from the delta and assign them to Config. Neither is
  a pnpm-workspace.yaml key, so they are special-cased like storeDir /
  catalogs rather than going through WorkspaceSettings::apply_to.
- Seed config.extra_env into every child-process spawn site: the
  install-family lifecycle scripts, run, recursive run, pack, publish,
  exec, and the dlx bin. Populated only by the hook, which today runs
  only for the install-family commands, so it is empty at the other
  sites until the hook broadens; wiring them uniformly keeps behavior
  consistent.
- Apply extra_env before pnpm's reserved per-call stamps in make_env, so
  a hook's extraEnv can't override INIT_CWD, PNPM_SCRIPT_SRC_DIR,
  npm_config_user_agent, or the verify-deps guard (matching TS
  runLifecycleHook); non-reserved keys still apply. The exec/dlx spawns
  layer pnpm's keys on top the same way.
- Forward config.extra_bin_paths to project lifecycle scripts, matching
  TS install/index.ts.

npmPath is intentionally not implemented: it is a type-only field on the
TypeScript Config that is never read as a value, and publish is native
on both stacks, so pacquet ignoring it already matches TypeScript
behavior.

This is a pacquet-only parity fix; the TypeScript CLI already has this
behavior, so no changeset is warranted.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    Pacquet-only parity fix: the TypeScript CLI already honors these fields
    because it passes the whole Config through updateConfig.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Not applicable — no published-package behavior changes; the
    TypeScript CLI already had this behavior.
  • Added or updated tests. Two unit tests in config_deps/tests.rs and one
    end-to-end lifecycle-script test in lifecycle_scripts.rs.
  • Updated the documentation if needed.

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

Summary by CodeRabbit

  • New Features

    • updateConfig hooks can now provide additional environment variables and binary paths.
    • Hook-provided environment variables are available to lifecycle scripts and spawned commands across supported operations.
    • Custom environment variables are preserved during installs, runs, packing, publishing, and execution.
  • Bug Fixes

    • Reserved package-manager environment values now reliably take precedence over custom values.
    • Added coverage ensuring lifecycle scripts receive configured values without overriding protected settings.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a817311-9a42-48bc-9692-2d0b4b73df07

📥 Commits

Reviewing files that changed from the base of the PR and between 342a3d3 and fcaa135.

📒 Files selected for processing (16)
  • pnpm/crates/cli/src/cli_args/dlx.rs
  • pnpm/crates/cli/src/cli_args/exec.rs
  • pnpm/crates/cli/src/cli_args/pack.rs
  • pnpm/crates/cli/src/cli_args/publish.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/config_deps.rs
  • pnpm/crates/cli/src/config_deps/tests.rs
  • pnpm/crates/cli/tests/lifecycle_scripts.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/executor/src/make_env.rs
  • pnpm/crates/executor/src/make_env/tests.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
📝 Walkthrough

Walkthrough

The change adds Config.extra_env, applies updateConfig hook updates to environment and binary-path settings, and propagates configured environment variables through CLI commands, packaging, publishing, and install lifecycle scripts with reserved-stamp precedence tests.

Changes

Extra environment propagation

Layer / File(s) Summary
Config hook support
pnpm/crates/config/src/lib.rs, pnpm/crates/cli/src/config_deps.rs, pnpm/crates/cli/src/config_deps/tests.rs
Config stores extra_env; updateConfig hooks receive and update extraEnv and extraBinPaths, with tests covering both values.
CLI command propagation
pnpm/crates/cli/src/cli_args/{dlx,exec,pack,publish,run}.rs, pnpm/crates/cli/src/cli_args/run/recursive.rs
Configured environment variables are forwarded to spawned commands, script runs, pack operations, and publish operations while later command-specific values are applied afterward.
Lifecycle environment propagation
pnpm/crates/package-manager/src/{install,install_frozen_lockfile,install_with_fresh_lockfile}.rs, pnpm/crates/package-manager/src/install_package_from_registry/tests.rs, pnpm/crates/cli/tests/lifecycle_scripts.rs
Install and build lifecycle environments start from config.extra_env; lifecycle scripts also receive configured binary paths, with tests covering propagation and reserved stamps.
Reserved environment precedence
pnpm/crates/executor/src/make_env.rs, pnpm/crates/executor/src/make_env/tests.rs
User-provided environment entries are applied before reserved per-call stamps, which override conflicting values while custom keys remain available.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UpdateConfigHook
  participant ConfigHooks
  participant Config
  participant CLICommands
  participant LifecycleScripts

  UpdateConfigHook->>ConfigHooks: return extraEnv and extraBinPaths
  ConfigHooks->>Config: update validated values
  Config->>CLICommands: provide extra_env
  Config->>LifecycleScripts: provide extra_env and extra_bin_paths
  CLICommands->>LifecycleScripts: pass environment with reserved stamps
Loading

Possibly related PRs

  • pnpm/pnpm#12400: Both changes modify lifecycle-script environment handling and precedence for user-provided npm_config_* values.
  • pnpm/pnpm#12910: Both changes modify environment stamping around VERIFY_DEPS_BEFORE_RUN_ENV and script execution.
  • pnpm/pnpm#12936: Both changes modify the run_update_config_hooks code path.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, KSXGitHub

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov-commenter

codecov-commenter commented Jul 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.42%. Comparing base (d3e1383) to head (fcaa135).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12943      +/-   ##
==========================================
+ Coverage   85.26%   85.42%   +0.16%     
==========================================
  Files         486      489       +3     
  Lines       77280    77849     +569     
==========================================
+ Hits        65890    66504     +614     
+ Misses      11390    11345      -45     

☔ 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 11, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 342a3d338ae9

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.891 ± 0.127 3.674 4.159 1.85 ± 0.07
pacquet@main 3.997 ± 0.180 3.741 4.311 1.90 ± 0.09
pnpr@HEAD 2.157 ± 0.108 2.040 2.347 1.02 ± 0.06
pnpr@main 2.105 ± 0.043 2.047 2.166 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8912902370199993,
      "stddev": 0.12744635685565917,
      "median": 3.88718005702,
      "user": 3.6718969799999996,
      "system": 3.4904693599999996,
      "min": 3.67374813602,
      "max": 4.15926824602,
      "times": [
        3.79187307202,
        3.81663841802,
        3.67374813602,
        3.90322601402,
        3.86130756802,
        3.92009526802,
        3.87113410002,
        3.94257976202,
        3.97303178602,
        4.15926824602
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.99704435362,
      "stddev": 0.1803636285128406,
      "median": 3.98197976502,
      "user": 3.6607750799999996,
      "system": 3.5086341599999997,
      "min": 3.74111481202,
      "max": 4.31100123402,
      "times": [
        4.04955304502,
        3.87260331802,
        4.10656497102,
        3.74111481202,
        4.31100123402,
        3.87004750002,
        4.21697200002,
        3.83862712602,
        3.91706935902,
        4.04689017102
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.15664374572,
      "stddev": 0.10816589832966503,
      "median": 2.12153150802,
      "user": 2.74004668,
      "system": 3.09611766,
      "min": 2.0404010810199997,
      "max": 2.3466591010199997,
      "times": [
        2.0614654780199997,
        2.34025375602,
        2.0857246900199997,
        2.3466591010199997,
        2.1284316840199997,
        2.12348388602,
        2.0404010810199997,
        2.20809760202,
        2.11957913002,
        2.11234104902
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1047473476199996,
      "stddev": 0.042875802712651324,
      "median": 2.10521757352,
      "user": 2.69447908,
      "system": 3.1066019600000003,
      "min": 2.04654237602,
      "max": 2.16640008002,
      "times": [
        2.16640008002,
        2.1201392650199997,
        2.1127645990199997,
        2.15560643102,
        2.09767054802,
        2.07659358702,
        2.04654237602,
        2.07560329402,
        2.14648744502,
        2.04966585102
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 670.3 ± 7.4 657.9 683.4 1.00
pacquet@main 696.8 ± 74.7 651.5 905.6 1.04 ± 0.11
pnpr@HEAD 727.6 ± 72.8 682.4 928.9 1.09 ± 0.11
pnpr@main 755.4 ± 21.1 737.9 803.0 1.13 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6702852108000001,
      "stddev": 0.007419734360383104,
      "median": 0.6706611594,
      "user": 0.39074064,
      "system": 1.3645284,
      "min": 0.6578743504000001,
      "max": 0.6834134664,
      "times": [
        0.6717881264000001,
        0.6681651324000001,
        0.6779058784,
        0.6640764254,
        0.6578743504000001,
        0.6635525344000001,
        0.6704023904,
        0.6709199284,
        0.6834134664,
        0.6747538754000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6967781437,
      "stddev": 0.0747180327437137,
      "median": 0.6790962489000001,
      "user": 0.39723023999999996,
      "system": 1.3602859999999999,
      "min": 0.6515237894,
      "max": 0.9055564454,
      "times": [
        0.6951312844,
        0.6886676194000001,
        0.6593759154000001,
        0.6789252304000001,
        0.6555241144,
        0.6734292954000001,
        0.6515237894,
        0.6792672674000001,
        0.6803804754,
        0.9055564454
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7276394614,
      "stddev": 0.07279384375671001,
      "median": 0.7110352429000001,
      "user": 0.41502884,
      "system": 1.3656544999999998,
      "min": 0.6824273504,
      "max": 0.9289029264,
      "times": [
        0.7216182094000001,
        0.6882234694,
        0.7004522764000001,
        0.6898210484,
        0.6824273504,
        0.6911327794000001,
        0.7222954264000001,
        0.7233349164,
        0.9289029264,
        0.7281862114000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7554220391000002,
      "stddev": 0.021065567480831476,
      "median": 0.7474248354,
      "user": 0.41454743999999993,
      "system": 1.4321597000000001,
      "min": 0.7378942164000001,
      "max": 0.8030015254,
      "times": [
        0.8030015254,
        0.7419140914000001,
        0.7378942164000001,
        0.7444410584000001,
        0.7504086124,
        0.7537500584000001,
        0.7573846654,
        0.7819918044,
        0.7435009774000001,
        0.7399333814000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.342 ± 0.055 4.249 4.410 1.97 ± 0.11
pacquet@main 4.304 ± 0.044 4.247 4.405 1.95 ± 0.11
pnpr@HEAD 2.209 ± 0.129 2.101 2.511 1.00 ± 0.08
pnpr@main 2.202 ± 0.123 2.081 2.441 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.34233304558,
      "stddev": 0.055013759820038866,
      "median": 4.34072513128,
      "user": 3.82803572,
      "system": 3.4799137599999996,
      "min": 4.24854879378,
      "max": 4.40977823678,
      "times": [
        4.324603269780001,
        4.39719650178,
        4.403940357780001,
        4.298729803780001,
        4.37620581378,
        4.40977823678,
        4.35036177278,
        4.282877415780001,
        4.33108848978,
        4.24854879378
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.304054993579999,
      "stddev": 0.04404891363210717,
      "median": 4.30090367978,
      "user": 3.74731302,
      "system": 3.4616643599999994,
      "min": 4.247441422780001,
      "max": 4.405127305780001,
      "times": [
        4.405127305780001,
        4.28467099678,
        4.32407691578,
        4.32076177278,
        4.29390857678,
        4.2972445307800005,
        4.251309384780001,
        4.311446200780001,
        4.30456282878,
        4.247441422780001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.20853256368,
      "stddev": 0.12872508337371544,
      "median": 2.1614959952799997,
      "user": 2.54027242,
      "system": 2.99083226,
      "min": 2.10091279878,
      "max": 2.51109059178,
      "times": [
        2.1672764337799997,
        2.2158050667799998,
        2.10091279878,
        2.1749462827799997,
        2.51109059178,
        2.36031417778,
        2.12913160478,
        2.1557155567799997,
        2.12510061778,
        2.1450325057799997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.2021221123799997,
      "stddev": 0.1229847589718072,
      "median": 2.1563478812799994,
      "user": 2.51146972,
      "system": 2.9950087599999997,
      "min": 2.08097097978,
      "max": 2.44110387778,
      "times": [
        2.1326790777799998,
        2.1731726867799996,
        2.1489724237799996,
        2.2414719977799997,
        2.0967960037799998,
        2.14427629778,
        2.1637233387799997,
        2.08097097978,
        2.3980544397799997,
        2.44110387778
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.376 ± 0.011 1.361 1.396 2.04 ± 0.02
pacquet@main 1.363 ± 0.061 1.315 1.526 2.02 ± 0.09
pnpr@HEAD 0.691 ± 0.083 0.651 0.927 1.02 ± 0.12
pnpr@main 0.674 ± 0.005 0.665 0.682 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.3764555713000002,
      "stddev": 0.01110734792633902,
      "median": 1.3738198027,
      "user": 1.30050492,
      "system": 1.7579504199999998,
      "min": 1.3614785222,
      "max": 1.3962478102,
      "times": [
        1.3962478102,
        1.3614785222,
        1.3695063892000001,
        1.3758447052,
        1.3705449692,
        1.3777888062,
        1.3687648362,
        1.3717949002,
        1.3944942682,
        1.3780905062
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3626253390999998,
      "stddev": 0.06056952745110461,
      "median": 1.3449133282,
      "user": 1.2845727200000001,
      "system": 1.72091702,
      "min": 1.3148765502000002,
      "max": 1.5263175732,
      "times": [
        1.3882784832000001,
        1.3381056802,
        1.3505372312000001,
        1.5263175732,
        1.3534426712,
        1.3452884312000002,
        1.3313251532,
        1.3148765502000002,
        1.3335433922000002,
        1.3445382252
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6909436678000002,
      "stddev": 0.0833730331735753,
      "median": 0.6658737402000001,
      "user": 0.34294592,
      "system": 1.2883303199999998,
      "min": 0.6514204292000001,
      "max": 0.9271737462,
      "times": [
        0.6676703552000001,
        0.6610675352000001,
        0.6514204292000001,
        0.9271737462,
        0.6776537612000001,
        0.6743943612000001,
        0.6656091442000001,
        0.6630179052,
        0.6661383362000001,
        0.6552911042
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6743677766,
      "stddev": 0.00548170166502661,
      "median": 0.6758185202,
      "user": 0.34115622,
      "system": 1.3050962199999998,
      "min": 0.6650013012000001,
      "max": 0.6817691502000001,
      "times": [
        0.6817691502000001,
        0.6744675862,
        0.6795481442000001,
        0.6779183272000001,
        0.6650013012000001,
        0.6759453832000001,
        0.6766952542000001,
        0.6756916572,
        0.6700056352000001,
        0.6666353272000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.146 ± 0.077 3.029 3.274 4.54 ± 0.14
pacquet@main 3.133 ± 0.131 2.978 3.316 4.52 ± 0.20
pnpr@HEAD 0.693 ± 0.012 0.676 0.711 1.00
pnpr@main 0.717 ± 0.012 0.697 0.731 1.03 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.14595252566,
      "stddev": 0.07661724267846128,
      "median": 3.14296558826,
      "user": 1.86854534,
      "system": 2.00022288,
      "min": 3.02860211326,
      "max": 3.27434302026,
      "times": [
        3.27434302026,
        3.18487350426,
        3.10205659626,
        3.06487189126,
        3.09541360926,
        3.12018348526,
        3.02860211326,
        3.16574769126,
        3.19945099226,
        3.22398235326
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.1333608376600006,
      "stddev": 0.13124092028035414,
      "median": 3.1308220002600002,
      "user": 1.8402064400000004,
      "system": 2.0253550799999998,
      "min": 2.97781633726,
      "max": 3.31619880026,
      "times": [
        3.22460060926,
        3.00059926726,
        2.97781633726,
        3.05924987326,
        2.98492288726,
        3.05099488826,
        3.28176082526,
        3.23507076126,
        3.31619880026,
        3.20239412726
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.69273633636,
      "stddev": 0.011827687458144338,
      "median": 0.69185671376,
      "user": 0.35896014,
      "system": 1.3247499799999998,
      "min": 0.67570438726,
      "max": 0.7106731442600001,
      "times": [
        0.7106731442600001,
        0.67570438726,
        0.6911764612600001,
        0.69253696626,
        0.6830612312600001,
        0.68859541526,
        0.69303936326,
        0.7096641692600001,
        0.68040889126,
        0.70250333426
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.71677862636,
      "stddev": 0.011782837778517597,
      "median": 0.7166859187600001,
      "user": 0.37964213999999996,
      "system": 1.3572269799999996,
      "min": 0.69698789526,
      "max": 0.73129887126,
      "times": [
        0.71203683326,
        0.72339721926,
        0.69698789526,
        0.70695594226,
        0.70759612926,
        0.72909554726,
        0.72984141126,
        0.73129887126,
        0.7092414102600001,
        0.7213350042600001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 673.5 ± 20.3 629.3 699.1 6.24 ± 0.20
pacquet@main 664.2 ± 20.1 627.2 686.3 6.15 ± 0.19
pnpr@HEAD 107.9 ± 0.9 106.2 109.6 1.00
pnpr@main 108.5 ± 2.0 105.7 113.4 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.67354179446,
      "stddev": 0.020342165618849307,
      "median": 0.67824959956,
      "user": 0.6320383199999999,
      "system": 0.16142182,
      "min": 0.62930894956,
      "max": 0.6991243865600001,
      "times": [
        0.6559253635600001,
        0.6991243865600001,
        0.6768857445600001,
        0.68470904956,
        0.68125449656,
        0.62930894956,
        0.66889832256,
        0.67961345456,
        0.6951708855600001,
        0.66452729156
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6641550434600001,
      "stddev": 0.020111558915582525,
      "median": 0.66887567906,
      "user": 0.63012592,
      "system": 0.15523552000000002,
      "min": 0.62717225056,
      "max": 0.68630114756,
      "times": [
        0.6814304535600001,
        0.66873406256,
        0.6532924895600001,
        0.6839181765600001,
        0.6792386825600001,
        0.62717225056,
        0.65169258756,
        0.66901729556,
        0.68630114756,
        0.64075328856
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10794328364000001,
      "stddev": 0.0008853908802570811,
      "median": 0.10775085956000001,
      "user": 0.028784180000000003,
      "system": 0.0186322,
      "min": 0.10618439056000001,
      "max": 0.10960848256,
      "times": [
        0.10834182456000001,
        0.10874354756,
        0.10726444056000001,
        0.10848771656,
        0.10681471056,
        0.10815732856,
        0.10898247256,
        0.10762078756,
        0.10772600356,
        0.10762477456,
        0.10775085956000001,
        0.10774582956,
        0.10876471556,
        0.10684300256,
        0.10948875956,
        0.10711289656,
        0.10718348956,
        0.10960848256,
        0.10618439056000001,
        0.10842390756,
        0.10864877856,
        0.10678947156,
        0.10728001056,
        0.10842938856,
        0.10856450156
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10852233396000001,
      "stddev": 0.001976325764032801,
      "median": 0.10791195156,
      "user": 0.02934662,
      "system": 0.018669919999999996,
      "min": 0.10569487456,
      "max": 0.11343584256,
      "times": [
        0.10780750556,
        0.11329002956,
        0.10569487456,
        0.10791195156,
        0.10804069156,
        0.10818501956,
        0.10858396756000001,
        0.10767508656000001,
        0.10930740056,
        0.10692761956,
        0.11018243856,
        0.10718091256000001,
        0.10874810456,
        0.10605545056,
        0.10882515856,
        0.10785946256000001,
        0.10700398356,
        0.10979243756,
        0.10676193056,
        0.11010748756000001,
        0.11148923956000001,
        0.10688927956000001,
        0.10775632856,
        0.10754614556,
        0.11343584256
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.692 ± 0.123 6.571 6.955 1.34 ± 0.03
pacquet@main 6.714 ± 0.235 6.438 7.145 1.34 ± 0.05
pnpr@HEAD 5.009 ± 0.083 4.906 5.173 1.00
pnpr@main 5.043 ± 0.092 4.895 5.181 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.691588219479999,
      "stddev": 0.1233731535745642,
      "median": 6.649725408579999,
      "user": 3.82994898,
      "system": 3.7199316000000002,
      "min": 6.57073404608,
      "max": 6.95522755808,
      "times": [
        6.60741665608,
        6.95522755808,
        6.84989424508,
        6.640197918079999,
        6.57073404608,
        6.60228308808,
        6.659252899079999,
        6.60739644108,
        6.68756351408,
        6.73591582908
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.71381351118,
      "stddev": 0.23501370035190083,
      "median": 6.67091844308,
      "user": 3.7902817799999995,
      "system": 3.714611,
      "min": 6.43801332208,
      "max": 7.14492556008,
      "times": [
        7.14492556008,
        6.74376878808,
        6.5829859190799995,
        6.43801332208,
        6.7455092270799994,
        6.737456325079999,
        6.58084012408,
        6.604380561079999,
        7.07772654408,
        6.482528741079999
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.00912409638,
      "stddev": 0.08326886154371585,
      "median": 4.9824501430799994,
      "user": 2.81887318,
      "system": 3.2796674,
      "min": 4.90605091808,
      "max": 5.17286930208,
      "times": [
        5.04012048108,
        4.90605091808,
        5.17286930208,
        4.9697901160799995,
        4.948388782079999,
        4.929036132079999,
        5.09851141308,
        5.06157353308,
        4.99224615208,
        4.97265413408
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 5.04344979438,
      "stddev": 0.09156772063664319,
      "median": 5.05135501158,
      "user": 2.7796528799999995,
      "system": 3.2727843,
      "min": 4.89481637708,
      "max": 5.181125039079999,
      "times": [
        5.04724093808,
        4.94945353108,
        4.989682903079999,
        5.181125039079999,
        5.089223660079999,
        4.89481637708,
        4.98337593308,
        5.0554690850799995,
        5.074786317079999,
        5.1693241600799995
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12943
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
4,342.33 ms
(+1.10%)Baseline: 4,295.20 ms
5,154.25 ms
(84.25%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,145.95 ms
(+3.84%)Baseline: 3,029.72 ms
3,635.67 ms
(86.53%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,376.46 ms
(+0.87%)Baseline: 1,364.55 ms
1,637.45 ms
(84.06%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
673.54 ms
(+4.74%)Baseline: 643.08 ms
771.70 ms
(87.28%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,891.29 ms
(-5.33%)Baseline: 4,110.57 ms
4,932.69 ms
(78.89%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,691.59 ms
(-8.92%)Baseline: 7,347.11 ms
8,816.54 ms
(75.90%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
670.29 ms
(+3.08%)Baseline: 650.24 ms
780.28 ms
(85.90%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12943
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
2,208.53 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
692.74 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
690.94 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
107.94 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,156.64 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,009.12 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
727.64 ms
🐰 View full continuous benchmarking report in Bencher

@TrevorBurnham
TrevorBurnham marked this pull request as ready for review July 11, 2026 21:09
@TrevorBurnham
TrevorBurnham requested a review from zkochan as a code owner July 11, 2026 21:09
Copilot AI review requested due to automatic review settings July 11, 2026 21:09
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@greptile-apps

greptile-apps Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The core wiring is correct for most spawn sites, but exec.rs has a behavioral gap that this PR exposes: a hook-set NODE_OPTIONS is overwritten when package_map_path_for_execution applies and config.node_options is unset.

The exec.rs change applies config.extra_env before pnpm's own PATH and user-agent, which is correct. But the NODE_OPTIONS computation that follows reads only from config.node_options, ignoring any NODE_OPTIONS the hook placed in extra_env. When package_map_path_for_execution returns a path and config.node_options is None, the generated package-map option overwrites the hook's value entirely and silently. run.rs handles this correctly by seeding node_options from extra_env first; exec.rs needs the same treatment.

pnpm/crates/cli/src/cli_args/exec.rs — the node_options computation at the package_map_path_for_execution block should be seeded from config.extra_env.get("NODE_OPTIONS") before applying make_node_package_map_option, mirroring the pattern in run.rs.

Comments Outside Diff (1)

  1. pnpm/crates/cli/src/cli_args/exec.rs, line 191-200 (link)

    P1 Hook NODE_OPTIONS silently dropped by package_map_path_for_execution

    When package_map_path_for_execution returns a path and config.node_options is None, node_options is seeded as None (line 191) and is then set to just the package-map option string (line 193). The cmd.env("NODE_OPTIONS", node_options) call that follows overwrites the hook's NODE_OPTIONS value that cmd.envs(&config.extra_env) already wrote at line 174.

    run.rs handles this correctly — it seeds extra_env from config.extra_env.clone(), lets config.node_options overwrite if set, and then reads extra_env.get("NODE_OPTIONS") as the base before calling make_node_package_map_option. The fix here is to mirror that pattern: seed node_options from config.extra_env.get("NODE_OPTIONS") when config.node_options is None before applying package_map_path_for_execution.

Reviews (4): Last reviewed commit: "fix(pacquet): keep npm_config_node_gyp o..." | Re-trigger Greptile

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.

Pull request overview

Brings the Rust pacquet CLI into parity with the TypeScript pnpm CLI by round-tripping extraBinPaths and extraEnv through the updateConfig pnpmfile hook and forwarding extra_env into child-process spawn sites (lifecycle scripts, run, exec, dlx, pack, publish), with added unit/e2e coverage.

Changes:

  • Added extra_env to pacquet Config and wired updateConfig hook seeding + delta re-application for extraBinPaths/extraEnv.
  • Forwarded config.extra_env into env construction across install/build and CLI command spawn paths.
  • Added tests validating updateConfig can extend extraBinPaths and set extraEnv, plus an e2e lifecycle-script assertion.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pnpm/crates/package-manager/src/install.rs Seeds lifecycle-script env with config.extra_env during install.
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs Seeds build/lifecycle env with config.extra_env for fresh-lockfile installs.
pnpm/crates/package-manager/src/install_package_from_registry/tests.rs Updates test config construction to include the new extra_env field.
pnpm/crates/package-manager/src/install_frozen_lockfile.rs Seeds build/lifecycle env with config.extra_env for frozen-lockfile installs.
pnpm/crates/config/src/lib.rs Adds Config::extra_env with documentation describing its source/semantics.
pnpm/crates/cli/tests/lifecycle_scripts.rs Adds e2e test ensuring updateConfig-set extraEnv reaches lifecycle scripts.
pnpm/crates/cli/src/config_deps/tests.rs Adds unit tests for updateConfig extending extraBinPaths and setting extraEnv.
pnpm/crates/cli/src/config_deps.rs Seeds hook input with extraBinPaths/extraEnv and re-applies them from the hook delta.
pnpm/crates/cli/src/cli_args/run/recursive.rs Starts recursive run env from config.extra_env.
pnpm/crates/cli/src/cli_args/run.rs Starts run env from config.extra_env.
pnpm/crates/cli/src/cli_args/publish.rs Forwards config.extra_env into publish script env/options.
pnpm/crates/cli/src/cli_args/pack.rs Forwards config.extra_env into pack options (and removes now-unneeded HashMap import).
pnpm/crates/cli/src/cli_args/exec.rs Applies config.extra_env into exec child-process env.
pnpm/crates/cli/src/cli_args/dlx.rs Threads extra_env into dlx bin spawn env and updates imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm/crates/cli/src/cli_args/run.rs Resolved
Comment thread pnpm/crates/cli/src/cli_args/publish.rs Resolved
Comment thread pnpm/crates/cli/src/cli_args/dlx.rs Resolved

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm/crates/package-manager/src/install.rs (1)

2220-2241: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Forward config.extra_bin_paths to project lifecycle scripts.

This path now forwards extra_env, but the same RunPostinstallHooks call still supplies extra_bin_paths: &[]. Consequently, extraBinPaths returned by updateConfig is ignored for project lifecycle scripts, despite the Config contract defining it as a PATH prefix for scripts. Pass &config.extra_bin_paths and add a regression that verifies the executable is visible inside the lifecycle script.

Suggested fix
         run_project_lifecycle_scripts::<Reporter>(&RunPostinstallHooks {
             dep_path: &dep_path,
             pkg_root: project_dir,
             root_modules_dir: &root_modules_dir,
             init_cwd: workspace_root,
-            extra_bin_paths: &[],
+            extra_bin_paths: &config.extra_bin_paths,
             extra_env: &extra_env,

Based on path instructions: REVIEW_GUIDE.md requires testing the real lifecycle effect, and pnpm/crates/config/src/lib.rs:1212-1222 defines extraBinPaths as script PATH prefixes.

🤖 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/package-manager/src/install.rs` around lines 2220 - 2241, Update
the RunPostinstallHooks construction in the project_manifests loop to pass
&config.extra_bin_paths instead of an empty slice, preserving the Config
extraBinPaths contract for lifecycle scripts. Add a regression test that runs a
project lifecycle script and verifies an executable from the configured extra
bin paths is available.

Source: Path instructions

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

951-955: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the redundant test narration.

The test name and assertion already express the contract. Keep comments only for non-obvious rationale; the TypeScript parity and PnpmBuild explanation duplicates information visible from the test itself.

As per path instructions, tests should express the contract once through assertions rather than duplicating the scenario in prose; this also follows the Rust comment guidance.

🤖 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 951 - 955, Remove
the redundant doc comment above the lifecycle-script test; the test name and
assertions already define the contract. Keep the test implementation and
assertions unchanged, retaining comments only if they explain non-obvious
rationale.

Sources: Coding guidelines, 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.

Outside diff comments:
In `@pnpm/crates/package-manager/src/install.rs`:
- Around line 2220-2241: Update the RunPostinstallHooks construction in the
project_manifests loop to pass &config.extra_bin_paths instead of an empty
slice, preserving the Config extraBinPaths contract for lifecycle scripts. Add a
regression test that runs a project lifecycle script and verifies an executable
from the configured extra bin paths is available.

---

Nitpick comments:
In `@pnpm/crates/cli/tests/lifecycle_scripts.rs`:
- Around line 951-955: Remove the redundant doc comment above the
lifecycle-script test; the test name and assertions already define the contract.
Keep the test implementation and assertions unchanged, retaining comments only
if they explain non-obvious rationale.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8daf8d2f-a048-437b-b8d5-2a4872041269

📥 Commits

Reviewing files that changed from the base of the PR and between 98722fa and 3acaffe.

📒 Files selected for processing (14)
  • pnpm/crates/cli/src/cli_args/dlx.rs
  • pnpm/crates/cli/src/cli_args/exec.rs
  • pnpm/crates/cli/src/cli_args/pack.rs
  • pnpm/crates/cli/src/cli_args/publish.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/config_deps.rs
  • pnpm/crates/cli/src/config_deps/tests.rs
  • pnpm/crates/cli/tests/lifecycle_scripts.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs

Copilot AI review requested due to automatic review settings July 11, 2026 22:13
@TrevorBurnham
TrevorBurnham force-pushed the feat/pacquet-update-config-extra-bin-paths-env branch from 3acaffe to 3eb213c Compare July 11, 2026 22:13

@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.

🧹 Nitpick comments (2)
pnpm/crates/executor/src/make_env/tests.rs (1)

177-213: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the early generated stamps in this regression.

The test validates INIT_CWD, user-agent, the verify-deps guard, and npm_lifecycle_script, but all of those are written after extra_env. It would still pass if extraEnv continued to overwrite npm_lifecycle_event or npm_package_*. Add conflicting entries and assert the authoritative generated values.

🤖 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/executor/src/make_env/tests.rs` around lines 177 - 213, Extend
reserved_stamps_win_over_extra_env_but_custom_keys_apply to include conflicting
extra entries for the early generated npm_lifecycle_event and at least one
npm_package_* value. Assert those generated values remain authoritative after
build_env, while preserving the existing CUSTOM assertion.
pnpm/crates/package-manager/src/install.rs (1)

481-490: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Keep the frozen-store validation out of this PR.

This behavior is unrelated to extraEnv/extraBinPaths propagation and expands the user-visible parity surface without a corresponding TypeScript change in the supplied context. Split it into a separate change, or add matching TypeScript behavior and tests.

As per path instructions, this PR should only change environment wiring and precedence.

Also applies to: 581-583

🤖 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/package-manager/src/install.rs` around lines 481 - 490, Remove
the frozenStore/force validation additions, including
ConfigConflictFrozenStoreWithForce and its associated handling around the
referenced validation code. Keep this PR scoped to extraEnv/extraBinPaths
environment wiring and precedence; defer frozen-store behavior to a separate
change unless matching TypeScript behavior and tests are added.

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.

Nitpick comments:
In `@pnpm/crates/executor/src/make_env/tests.rs`:
- Around line 177-213: Extend
reserved_stamps_win_over_extra_env_but_custom_keys_apply to include conflicting
extra entries for the early generated npm_lifecycle_event and at least one
npm_package_* value. Assert those generated values remain authoritative after
build_env, while preserving the existing CUSTOM assertion.

In `@pnpm/crates/package-manager/src/install.rs`:
- Around line 481-490: Remove the frozenStore/force validation additions,
including ConfigConflictFrozenStoreWithForce and its associated handling around
the referenced validation code. Keep this PR scoped to extraEnv/extraBinPaths
environment wiring and precedence; defer frozen-store behavior to a separate
change unless matching TypeScript behavior and tests are added.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 25c8c0e7-bc29-41d9-bb54-053e73762ee4

📥 Commits

Reviewing files that changed from the base of the PR and between 3acaffe and 3eb213c.

📒 Files selected for processing (16)
  • pnpm/crates/cli/src/cli_args/dlx.rs
  • pnpm/crates/cli/src/cli_args/exec.rs
  • pnpm/crates/cli/src/cli_args/pack.rs
  • pnpm/crates/cli/src/cli_args/publish.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/config_deps.rs
  • pnpm/crates/cli/src/config_deps/tests.rs
  • pnpm/crates/cli/tests/lifecycle_scripts.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/executor/src/make_env.rs
  • pnpm/crates/executor/src/make_env/tests.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
✅ Files skipped from review due to trivial changes (1)
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
🚧 Files skipped from review as they are similar to previous changes (11)
  • pnpm/crates/cli/src/cli_args/publish.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/cli/src/cli_args/exec.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/pack.rs
  • pnpm/crates/cli/src/config_deps.rs
  • pnpm/crates/cli/src/cli_args/dlx.rs
  • pnpm/crates/cli/src/config_deps/tests.rs

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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Comment thread pnpm/crates/cli/src/cli_args/dlx.rs Resolved
Comment thread pnpm/crates/cli/src/cli_args/pack.rs Resolved
Comment thread pnpm/crates/cli/src/cli_args/publish.rs Resolved
Comment thread pnpm/crates/cli/src/cli_args/publish.rs Resolved
Comment thread pnpm/crates/executor/src/make_env.rs Resolved
@TrevorBurnham

Copy link
Copy Markdown
Contributor Author

Addressed the automated review in 3eb213c (also rebased on main to clear the conflicts):

  • Env precedence (CodeRabbit + Copilot ×6): build_env applied extra_env last, letting a hook's extraEnv override pnpm's reserved stamps (INIT_CWD, PNPM_SCRIPT_SRC_DIR, npm_config_user_agent, the verify-deps guard). TS runLifecycleHook spreads extraEnv before those keys, so pnpm wins. Now applied before the reserved stamps; non-reserved extraEnv keys still take effect. Covered by a unit test and an e2e regression.
  • extra_bin_paths: &[] for project lifecycle scripts (CodeRabbit): now forwards &config.extra_bin_paths, matching TS install/index.ts which passes extraBinPaths to the root scripts.
  • dlx comment wording (Copilot): corrected — dlx doesn't run updateConfig, so its extra_env is currently always empty; the wiring stays for uniformity.

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

Copilot AI review requested due to automatic review settings July 12, 2026 01:42

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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

TrevorBurnham and others added 5 commits July 13, 2026 14:34
…sites

Address review of the extraEnv wiring: the publish lifecycle scripts, the
pnpm exec child, and the dlx bin spawn did not forward config.extra_env,
unlike the pack path and the install-family lifecycle sites. None is a
live bug today (extra_env is populated only by the updateConfig hook,
which currently runs only for install-family commands, so it is empty at
these sites), but the asymmetry was inconsistent and the Config::extra_env
doc comment overstated the reach.

- publish: run_publish_scripts now passes &config.extra_env instead of an
  empty map.
- exec: spawn_in_dir applies config.extra_env before pnpm's own keys, so
  PATH/user-agent/NODE_OPTIONS still win on conflict (matching TS makeEnv).
- dlx: run_bin takes an extra_env argument and applies it the same way.
- Config::extra_env: doc comment now states the hook runs only for
  install-family commands, so other commands' spawn sites read an empty
  map until the hook broadens.
Address PR review. Now that config.extra_env carries the user's
updateConfig extraEnv (not just pnpm-controlled values), applying it
last in build_env let a hook override pnpm's reserved per-call stamps
(INIT_CWD, PNPM_SCRIPT_SRC_DIR, npm_config_user_agent, the
verify-deps-before-run guard). TS runLifecycleHook spreads extraEnv
before those keys, so pnpm wins on conflict.

- make_env: apply extra_env before the reserved per-call stamps, so
  pnpm's stamps override it; a non-reserved extraEnv key still applies.
  Update the docs and the precedence test accordingly.
- install: forward config.extra_bin_paths to project lifecycle scripts
  instead of an empty slice, matching TS (install/index.ts passes
  extraBinPaths to the root scripts).
- dlx: correct the extra_env comment — dlx does not run updateConfig, so
  the map is currently always empty there.
- Add an e2e regression asserting a hook extraEnv cannot override
  INIT_CWD.
The make_env doc described extra_env as purely the user's updateConfig
extraEnv, but callers merge pnpm-controlled keys (e.g. NODE_OPTIONS from
nodeOptions) into it before build_env sees it. Widen the EnvOptions
field doc and the step-4 comment to say extra_env carries the user
extraEnv plus any pnpm-controlled keys the caller adds, and that the
reserved per-call stamps override all of it regardless of origin. The
precedence contract is unchanged.
Applying config.extra_env before the reserved per-call stamps also
moved it after the npm_config_node_gyp insertion, so a hook's extraEnv
could no longer override npm_config_node_gyp. That diverges from TS
npm-lifecycle, which sets npm_config_node_gyp before spreading extraEnv,
leaving it overridable. It is not one of pnpm's reserved stamps
(INIT_CWD, PNPM_SCRIPT_SRC_DIR, npm_config_user_agent, the verify-deps
guard, npm_lifecycle_script), and neither the make_env doc nor the PR
description lists it as one.

Stamp npm_config_node_gyp before extra_env so a hook extraEnv wins,
matching TS. Extend the reserved-stamps unit test to assert that the
non-reserved stamps generated before extra_env (npm_lifecycle_event,
npm_config_node_gyp, npm_package_*) stay overridable.
@zkochan
zkochan force-pushed the feat/pacquet-update-config-extra-bin-paths-env branch from 342a3d3 to fcaa135 Compare July 13, 2026 13:05
Copilot AI review requested due to automatic review settings July 13, 2026 13:05

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.

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. extraBinPaths unvalidated in PATH 🐞 Bug ⛨ Security
Description
run_update_config_hooks assigns hook-returned extraBinPaths directly into
config.extra_bin_paths with no validation/normalization, and install now forwards that list into
lifecycle PATH construction. Because the lifecycle PATH join is explicitly non-validating, a hook
can accidentally (or intentionally) introduce path-separator/empty/relative entries that alter PATH
semantics and executable resolution during lifecycle script runs.
Code

pnpm/crates/cli/src/config_deps.rs[R492-516]

+    // `extraBinPaths` / `extraEnv` aren't `WorkspaceSettings` fields, so
+    // `from_value(delta)` below ignores them. Pull the hook's values out
+    // first and assign them directly.
+    let changed_extra_bin_paths = delta
+        .get("extraBinPaths")
+        .map(|value| serde_json::from_value::<Vec<PathBuf>>(value.clone()))
+        .transpose()
+        .into_diagnostic()
+        .wrap_err("the updateConfig hook produced an invalid extraBinPaths value")?;
+    let changed_extra_env = delta
+        .get("extraEnv")
+        .map(|value| serde_json::from_value::<HashMap<String, String>>(value.clone()))
+        .transpose()
+        .into_diagnostic()
+        .wrap_err("the updateConfig hook produced an invalid extraEnv value")?;
    let delta_settings: WorkspaceSettings = serde_json::from_value(delta)
        .into_diagnostic()
        .wrap_err("deserialize the updateConfig hook result")?;
    delta_settings.apply_to(config, &base_dir);
+    if let Some(extra_bin_paths) = changed_extra_bin_paths {
+        config.extra_bin_paths = extra_bin_paths;
+    }
+    if let Some(extra_env) = changed_extra_env {
+        config.extra_env = extra_env;
+    }
Evidence
The hook’s extraBinPaths is pulled from the delta and assigned directly to
config.extra_bin_paths, and install now forwards that list into lifecycle spawns. Lifecycle PATH
construction uses a join routine documented as doing “no validation”, unlike exec/dlx which
explicitly reject delimiter-containing PATH dirs—so hook-provided values can affect PATH parsing and
command resolution.

pnpm/crates/cli/src/config_deps.rs[400-516]
pnpm/crates/package-manager/src/install.rs[2224-2266]
pnpm/crates/executor/src/extend_path.rs[84-99]
pnpm/crates/cli/src/cli_args/exec.rs[213-227]
pnpm/crates/cli/src/cli_args/dlx.rs[554-563]

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

### Issue description
`updateConfig` hook output for `extraBinPaths` is deserialized and assigned into `Config` without validation or normalization. Those paths are later used to build `PATH` for lifecycle script spawns using a lossy join that does not reject embedded path delimiters, and relative/empty entries can change PATH meaning (e.g., create extra PATH components or resolve relative to the child cwd).

### Issue Context
- `run_update_config_hooks` reads `extraBinPaths` from the hook delta and assigns it directly to `config.extra_bin_paths`.
- Project lifecycle scripts now receive `config.extra_bin_paths`.
- Lifecycle PATH joining is intentionally “no validation”, unlike `exec`/`dlx` which explicitly reject delimiter-containing entries.

### Fix Focus Areas
- pnpm/crates/cli/src/config_deps.rs[492-516]
- pnpm/crates/package-manager/src/install.rs[2234-2256]
- pnpm/crates/executor/src/extend_path.rs[84-99]

### What to change
1. After deserializing `changed_extra_bin_paths`, validate each entry before assigning:
  - Reject any entry whose string form contains the platform PATH delimiter (`:` on POSIX, `;` on Windows), matching the `exec`/`dlx` guards.
  - Reject empty paths (to avoid creating empty PATH components).
  - Consider resolving relative paths against `base_dir` (workspace-root anchor used by other path-like settings) to avoid cwd-dependent behavior.
2. Add a unit test in `pnpm/crates/cli/src/config_deps/tests.rs` that a hook returning an `extraBinPaths` entry containing the delimiter is rejected with the intended error message.

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



Informational

2. Stale pack extraEnv comment 🐞 Bug ⚙ Maintainability
Description
pack.rs still claims extraEnv is not surfaced by Config, but this PR now forwards
config.extra_env into PackOptions. This comment is now misleading for future maintainers and
reviewers.
Code

pnpm/crates/cli/src/cli_args/pack.rs[241]

+            extra_env: config.extra_env.clone(),
Evidence
The file-level doc claims extraEnv isn’t surfaced by Config, but the PackOptions builder now sets
extra_env: config.extra_env.clone(), contradicting that statement.

pnpm/crates/cli/src/cli_args/pack.rs[1-12]
pnpm/crates/cli/src/cli_args/pack.rs[230-242]

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 module-level comment in `pack.rs` says `extraEnv` is not surfaced by `Config` yet, but the code now passes `config.extra_env` into `PackOptions`.

### Issue Context
This PR changes pack to forward `config.extra_env`, so the documentation at the top of the module is now stale.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pack.rs[8-12]
- pnpm/crates/cli/src/cli_args/pack.rs[230-242]

### What to change
Update or remove the outdated sentence so it reflects current behavior (e.g., keep the `embedReadme` note, but remove `extraEnv` from the “not surfaced” list, or describe that `extra_env` is wired but typically empty unless populated by hooks in the invoking command).

ⓘ 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.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@zkochan
zkochan merged commit 1adc62c into pnpm:main Jul 13, 2026
30 checks passed
@qodo-code-review qodo-code-review Bot mentioned this pull request Sep 27, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants