Skip to content

[pull] main from pnpm:main - #444

Merged
pull[bot] merged 22 commits into
dwongdev:mainfrom
pnpm:main
Jul 25, 2026
Merged

pull[bot] merged 22 commits into
dwongdev:mainfrom
pnpm:main

Conversation

@pull

@pull pull Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

zkochan and others added 22 commits July 25, 2026 12:16
…kspace (#13297)

`pnpm --dir ../../elsewhere add -w foo` from inside a workspace added to
that workspace's root instead of failing, when `../../elsewhere` did not
exist. pnpm reports ERR_PNPM_NOT_IN_WORKSPACE.

`apply_workspace_root` falls back to `std::path::absolute` when the `--dir`
cannot be canonicalized, which is what keeps a nonexistent `--dir` inside
the workspace working. On Unix that leaves `..` components in place, and
`find_workspace_dir` walks ancestors lexically — so the walk climbed back
up through the very `..` components that had taken it out of the workspace
and found the workspace it had just left.

Resolve `..` in the fallback with `pacquet_fs::lexical_normalize` (the
existing filesystem-free normalizer) before the walk. A nonexistent `--dir`
that stays inside the workspace still resolves to the root, and an existing
directory outside it still errors — both already covered by tests.

Found by CodeRabbit on #13294, a duplicate of #13281
closed in favor of it; the finding applies to the merged implementation.
Verified against the TypeScript CLI: all three `--dir` shapes now agree.
pnpm stops parsing at the script name: `run` is in
`SPECIALLY_ESCAPED_CMDS`, so nopt is told to escape from
`argv.remain[indexOfRunScriptName]` onward and every later token reaches
the script untouched. pacquet instead let clap keep parsing, because
`RunArgs` declared the script name as its own `Option<String>` positional
ahead of the `trailing_var_arg` argument list. clap only flips
`trailing_values` when a `trailing_var_arg` positional takes its first
value, so with the name consumed by the earlier positional the next `--`
hit the escape branch and was discarded — and pnpm's own `run` flags kept
matching past the script name.

Six observable divergences, all from that one shape:

    command                       pnpm            pacquet
    run show -- --other=1         -- --other=1    --other=1
    run show -- -s                -- -s           -s
    run show -- a b               -- a b          a b
    run show -- --                -- --           --
    run show -s                   -s              (--sequential)
    run show --if-present         --if-present    (--if-present)

The dropped separator is the damaging one: `node`, `jest`, `tsc` and the
like then claim the forwarded option themselves, so `pnpm run test --
--watch` fails instead of running.

Collapse the two positionals into the single `trailing_var_arg` vec that
`exec` / `dlx` / `with` already use, which puts the escape boundary
exactly at the script name. Flags ahead of the script name still parse as
pnpm's.

Closes #13295
A `packages:` pattern whose directory does not exist made every command
fail with ERR_PNPM_WORKSPACE_WALK_ERROR, because the project enumeration
propagated every error the glob walk produced — including the ENOENT wax
reports for the absent directory. pnpm's walk simply matches nothing, so a
workspace that declares `packages/*` before creating `packages/` was
unusable until the directory was made by hand: `install`, `run`, and
`list` all aborted.

Absorb `NotFound` from the walk. Getting the kind at all needed the
conversion fixed too: the arm restringified the wax error through
`io::Error::other`, which discards the underlying `ErrorKind`, so the
`io::Error::from` impl is used instead and callers now also see the real
kind.

`NotFound` is now absorbed in two places here — the walk, and the manifest
read for a file that vanished after being listed — so the shared rationale
moves to one comment above both. Every other kind still propagates, which
a new test pins: an existing-but-unreadable pattern directory is a real
failure, not an empty match.

Closes #13296
…equired dependency (#13289)

`packageIsInstallable` is called with `optional: pkgSnapshot.optional === true`
everywhere on the headless path — the lockfile filter, the dep-graph builder,
and the hoisted-linker graph builder — while the resolver calls it with the
optionality of the dependency *edge* it is following. The two disagree
whenever a package is reached through a regular `dependencies` edge but its
whole subtree hangs off an `optionalDependencies` entry, because the resolver
propagates `optional: true` onto every snapshot in such a subtree. A fresh
resolve then fails that shape under `engineStrict` while
`pnpm install --frozen-lockfile` on the very same lockfile succeeds.

Classify by edge on the headless path too. `filterLockfileByImportersAndEngine`
now walks the lockfile breadth-first over edges, expanding a package's edges
only once the package is itself known to be part of the install, and returns
the resulting `requiredDepPaths` set for the two graph builders to dispatch on.
Breadth-first over edges rather than depth-first over packages keeps the
verdict independent of which edge reaches a package first, so a package left
out on an optional edge is reconsidered when a non-optional one arrives.

Classification has to run before anything is reported, since a package can be
visited once per inbound edge and `packageIsInstallable` logs on every call.
`checkPackageInstallability` is split out of it as the pure verdict, so the
walk can classify silently and each package is reported exactly once
afterwards — no duplicated `skippedOptionalDependencyLogger` entries.

The Rust CLI has dispatched per edge on both paths since #13172, so
this closes the resulting cross-stack gap; a pacquet test pins the frozen-path
behavior that previously only differed by stack.

Closes #13286.
#13306)

With nodeLinker=hoisted, every workspace project got a link to each of its
direct dependencies, including the ones already materialized in the
workspace-root node_modules. Node resolution walks up from the project, so
that second entry is redundant — and it is a second copy for the build
pass to run lifecycle scripts in.

pnpm nests a copy only for the versions that lost the root slot. Upstream's
map comes from the hoisting hierarchy, so a dependency the hoister moved to
the root is simply absent from the importer's entry; pacquet derives it from
the importer's lockfile declarations, which keeps the winner in the map, so
the link pass has to recognize and skip it.

The workspace root itself is exempt: it owns the hoisted slot, and its
entries are the real directories rather than links to them.

Two tests asserted the old shape and now pin the upstream rule, and the
known-failure stub registered for this divergence
(hoisted_workspace_duplicate_materialization) becomes a real assertion in
run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker.

Refs #13167
Two passes rewrite argv before clap sees it, and neither stopped where
pnpm stops parsing, so tokens meant for a script were consumed or
rewritten on the way through:

    command                              pnpm            pacquet
    run show --config.foo=bar            forwarded       swallowed
    run show --silent                    --silent        --reporter=silent
    exec node show.js --config.foo=bar   forwarded       swallowed

The `--silent` case is the worse one: the script received a token the user
never typed, not merely one fewer.

`ConfigOverrides::extract` stopped at an explicit `--` and at
`external_command_index`, the first positional naming no known command.
That covers the `pnpm <script>` fallback but not an explicit `run` /
`exec`, where the command *is* known, so no boundary was found and the
scan covered the whole argv. `expand_universal_shorthands` stopped only at
`--`.

Rather than give the shorthand pass a third boundary rule, both now
consult one `parse_boundary::passthrough_from`: the first index that must
reach the child untouched, whether that comes from a `--`, the fallback
command, or a command taking a foreign command line (`run` / `exec` /
`dlx` / `with` — pnpm's `SPECIALLY_ESCAPED_CMDS` plus `exec`). The
separator is scanned independently of the command, so `pnpm install --
--config.foo=bar` still ends parsing.

`recursive` / `multi` / `m` defer the classification by one positional, so
`pnpm -r run build --silent` lands on the same boundary. A package sharing
an escaping command's name does not: `pnpm add run --config.foo=bar` keeps
the setting, because only the command position is classified.

One existing shorthand test asserted the old behavior — that `--silent`
"stays universal" past the script name. Both stacks disagree with it:
`pnpm run show --silent` forwards the flag and does not silence the echo,
while `pnpm run --silent show` silences it. Split into the two positions.

Closes #13302
pnpm 10 serializes each `patchedDependencies` entry as a `{hash, path}`
mapping, while pnpm 11 and later write the bare patch-file hash. The
`Lockfile::patched_dependencies` field typed the values as plain strings,
so a lockfile committed by pnpm 10 failed to parse and every install --
frozen and non-frozen alike -- aborted with ERR_PNPM_BROKEN_LOCKFILE
before it could regenerate anything.

Deserialize the field through an untagged entry that accepts both shapes
and collapses the mapping to its hash, mirroring
`migratePatchedDependencies` in the TypeScript CLI. The path is redundant
-- patch paths come from the project's `patchedDependencies` config -- and
the writer already emits the bare hash, so such a lockfile installs
unchanged and normalizes the next time it is written.

Closes #13307
…8 BOM (#13327)

serde_json rejects a leading byte order mark, so a manifest carrying one
failed the whole read with "expected value at line 1 column 1". Workspace
discovery aborted on it, which made pnpm 12 unusable in repositories that
keep such a manifest on purpose — vitejs/vite ships
playground/resolve/utf8-bom-package/package.json and matches it with its
workspace patterns.

Route every manifest parse through parse_manifest / parse_manifest_bytes,
which drop the BOM first. pnpm decodes manifests through strip-bom and
TextDecoder, so both stacks now accept the same files: project manifests,
dependency manifests read from node_modules, and the package.json bundled
in a tarball. The BOM only disappears from a file once a real change makes
the writer emit the manifest afresh.

A manifest that really is malformed now reports its path, which the
workspace-discovery diagnostic previously omitted.

Closes #13311
…13299)

`pnpm add <pkg>@workspace:...` recorded the specifier exactly as typed,
so `workspace:^1.2.3` stayed pinned where pnpm writes `workspace:^` — a
range with no version in it, so bumping the workspace package never has
to touch its dependents' manifests.

`update --workspace` already had a private calculator for this. It moves
to the npm-resolver crate so both commands share it, and it renders
only: whether a dependency should be written under the protocol at all
stays with the caller, because the two differ. `update --workspace` is
an explicit request and writes a `workspace:` specifier even under
`saveWorkspaceProtocol: false`, while `add` falls back to a registry
range.

`add` needs its own entry point because it writes the manifest before
the install runs and so never reaches the resolver's `calc_specifier`
path. The workspace is enumerated only for the shapes that carry a
version; the rolling default reads nothing extra.

Also adds the missing `PNPM_CONFIG_SAVE_WORKSPACE_PROTOCOL` binding.

Related to #12042.
`approve-builds` declared `--global` without the `-g` short form its ten
peers all carry, so `pnpm approve-builds -g` died in the argument parser
instead of reaching pnpm's own
ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL. pnpm accepts `-g`
wherever it accepts `--global`.

The `--workspace-root` conflict table now runs over both spellings, which
is the property that was missing: it used the long form throughout
precisely because this one command rejected the short one, so the gap it
had surfaced went unasserted. Dropping the short form again fails the
table, naming the subcommand and the spelling.

Closes #13310
…oad (#13339)

add_resolves_package_selectors_concurrently_and_reports_in_selector_order
failed intermittently during a full-suite run and passed on a re-run. Its
mock handlers block on a condvar until all three latest requests have
started, capped at 2 seconds, and the wait result was discarded — so a
machine too loaded to dispatch the third request in time was
indistinguishable from a genuine loss of concurrency, and the overlap
assertion failed with nothing pointing at the real cause.

Give the barrier a budget that outlasts scheduling latency on a machine
running the whole suite in parallel, and record the expiry: the first
handler to give up marks the barrier dead so its peers stop waiting, which
keeps a real regression to one timeout instead of one per selector, and the
assertion now says the requests never overlapped instead of only reporting
a count mismatch. Verified by making the resolution loop sequential, which
fails with that message.

add_does_not_wait_for_a_slower_later_resolution_after_an_error reads the gap
between a fast failing selector and a slow peer through a wall-clock
deadline. 100 ms against 3 s left only ~2 s of slack for the fast path;
widening the peer to 20 s and the deadline to 5 s keeps the same claim with
room for a loaded machine. The mock's sleep does not delay teardown, so the
longer delay costs nothing.

LinkConcurrencyProbe carried the same 2-second barrier for
cold_batch_links_slots_in_parallel and gets the same treatment.

Closes #13328
)

The `with-registry` jest preset built its verdaccio-shaped storage into
a fresh mkdtemp directory on every run, but globalTeardown only killed
the server — the directory was never removed, so every run of every
registry-backed suite leaked one permanently (~2 MB for a small suite,
up to ~2 GB for suites that proxy real packages).

On a tmpfs /tmp they accumulate until it fills, and the suite then fails
with ENOSPC in whichever test happens to write next — which reads as
flakiness, since a different test fails each run and each passes in
isolation.

globalSetup now hands the path it created to globalTeardown through
`global`, the same way it already hands over killServer, so teardown
removes only that run's directory. Removal happens after the server is
killed, since pnpr writes proxy-cache entries into the storage while
serving. A failed removal warns rather than throwing.

Related to #13328.
…pt (#13344)

pnpm has no commands by these names: they reach `run` through the
`pnpm <script>` fallback, so parsing stops at the command name and every
later token is the script's. pacquet registered them as commands, so clap
parsed their arguments — `test` and `start` declared none at all and
rejected everything, and `stop` claimed the tokens it recognized:

    pnpm test --watch          usage error        -> forwarded
    pnpm test -- --flag        usage error        -> ["--", "--flag"]
    pnpm stop --if-present     taken as the flag  -> forwarded
    pnpm stop -s               taken as the flag  -> forwarded
    pnpm stop -- --other=1     ["--other=1"]      -> ["--", "--other=1"]

Give all three the single trailing_var_arg shape `run` got in
#13300, through a shared ScriptShortcutArgs, and teach the
parse boundary that their arguments start right after the command name.
`restart` is a real command upstream, with its own --if-present, and is
left as it is.

A leading `--` needs one extra step: clap consumes it as its own escape
until the positional has taken a value, and a shortcut's arguments can
open on it because no script name precedes them. `leading_separator`
writes a second one there, keyed off the boundary scan reporting that the
command is a shortcut — the boundary alone is not enough, since for `run`
it points past the script name, where clap already keeps the separator.

Two consequences worth naming, both of them the parity behavior:
`pnpm test -s` no longer silences pnpm's own reporter, and
`pnpm stop --if-present` no longer skips a missing script — for either,
the flag must precede the command name, as it must under pnpm.

Closes #13301

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…rom (#13337)

Inside a workspace the interactive update list showed no way to tell
which project an outdated dependency belonged to, so the same package
outdated in two projects rendered as two indistinguishable rows.

Every outdated entry now records the name of the project it was
collected from, and the interactive list gains the `Workspace` column
upstream shows when workspaces are enabled. The name is read where the
collector already has the manifest in hand, so nothing new is threaded
through; it is stripped of control characters with the rest of the row.

This completes the interactive parity item of #12101, whose
remaining half after the grouping landed was this column.

Related to #12101.
`TempDir::keep()` disables cleanup, and three of the four sites using it did
not need to: the `'static` requirement was on the value being leaked
(`StoreDir`, `Config`), never on the directory. A full run left ~45
directories in the system temp dir; it now leaves ~10.

- `overrides::tests::manifest_from_value` wrote a `package.json` only to read
  it straight back, for a path its own doc calls a stub. It builds the
  manifest with `PackageManifest::from_value` instead, which touches no
  filesystem at all — one leak per call across ~25 callers, gone, and the
  helper drops to one line.
- `env_installer::tests::harness` leaked the store directory alongside the
  `&'static StoreDir` pointing at it. The `TempDir` moves into `Harness`,
  which already exists to hold per-test handles.
- `install_package_from_registry::tests::create_config` leaked a cache dir
  while every caller was separately creating one of its own and passing it
  to the resolver. It takes the caller's, so the config and the resolver now
  share a cache the way they do in practice.

`cli/tests/pnpr_install.rs` keeps its `keep()`: the detached server thread
outlives both the function and the test.

Add `just sweep-test-temp` for the rest. A killed test process cannot run
`Drop`, so a fail-fast or interrupted run always abandons whole fixture
trees, including a per-test store for the mocked-registry tests. The sweep
skips anything under an hour old so it cannot disturb a concurrent run.

Redirecting `TMPDIR` at the whole suite does not work: tests assert on
stderr containing paths under the temp dir, and a `TMPDIR` under `target/`
makes the walk for `pnpm-workspace.yaml` find this repo's own.

Related to pnpm/pnpm#12485.
…s deps (#13343)

`resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a
missing peer from the workspace root's dependencies. The picker was fed
`self.direct` — the deps of whichever importer was being resolved — so a
project that didn't declare the peer itself saw no candidate and resolved
a second copy from the registry. The field doc said as much
("Single-importer pacquet treats the importer as the root"), left over
from before the multi-importer orchestrator existed.

`resolve_workspace` now builds the root importer's list once, after the
phase-1 init barrier, and shares it with every importer's hoist rounds;
computing it once also matches pnpm, where the root's own hoisted peers
never become root-dep candidates for the importers hoisted after it. An
importer set without the root leaves the list empty, mirroring pnpm's
absent-root-importer case.

`build_workspace_root_deps` also needed pnpm's two specifier sources to
be of any use: the resolver reports `normalized_bare_specifier` only for
specs that needed normalizing, so a plain "19.2.0" arrived as `None` and
the picker skipped the root dep entirely. Fall back to the declared
specifier, and include deps the resolver couldn't name at resolution
time (git / tarball / local), matching `getHoistableRootDeps`.

Separately, `get_hoistable_optional_peers` now checks ranges with plain
semver instead of the prerelease-tolerant helper, matching the bare
`semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a
stand-in for a range that didn't ask for one: `ts-jest` declares
`@jest/transform` and `jest-util` as optional peers with
`^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph
was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29.

Both were found resolving vercel/next.js, whose `overrides` pin `react`
to one canary build: pnpm 12 produced a second `[email protected]` and paired
it with the canary `react-dom`, violating that package's exact peer pin.
The remaining required-peer prerelease divergence is #13341.

Related to #13320.
Registry package manifests may express `libc` as a plain string. Pacquet's
dependency-graph-to-lockfile conversion only accepted arrays, so fresh
lockfiles silently omitted those platform constraints.

Accept both string and array `libc` metadata in that conversion while keeping
other manifest list fields array-only. Cover the scalar form with a regression
test based on sass-embedded's Linux variants, including a check that malformed
scalar bundle metadata remains ignored.

Closes #13324.
…ty (#13349)

pnpm refused every tarball resolution without an `integrity`, including
the commit-pinned git-host archives older pnpm versions wrote without
one, so a committed lockfile carrying such an entry could not be
installed at all.

The exemption now follows pnpm's `classifyResolution`: a git-host
archive URL or a `file:` tarball may be fetched unverified, every other
remote tarball still has to pin a hash. The check keys off the URL
rather than the lockfile's `gitHosted` marker, which pnpm treats as a
hint. `DownloadTarballToStore::package_integrity` became
`Option<&Integrity>`; an unverified fetch also claims no `index.db`
row, because the key pnpm addresses such a package by
(`pickStoreIndexKey`'s `pkg_id\tbuilt` fallback) is the one the
git-hosted prepare pass writes the prepared file set to — the raw
archive must not land there. The warm-path key derivation now goes
through `pick_store_index_key`, so it agrees with that fallback.

The prepare + packlist dispatch and the warm-cache key follow the same
classification, from the flag or the URL, so an entry cannot be exempt
from verification while skipping preparation; and a shape the fetch
refuses gets no warm key at all, so a row already at the shared
`pkg_id\tbuilt` key cannot materialize it before the refusal runs.

The refusal that remains carries pnpm's message and a `help:` line
naming the repair (`pnpm clean --lockfile`, then `pnpm install`), which
re-resolves the entry and records the hash.

Closes #13308.
The `Workspace` column falls back to the project's lockfile path when a
workspace project declares no `name` or an empty one, because either
renders a blank label. A name of `"   "` is truthy and non-empty, so it
slipped past that guard and rendered just as blank.

Both stacks now trim before deciding, and the fallback tests cover the
absent, empty, and whitespace-only shapes together.

Follow-up to #13337, which landed the column and the first two
shapes.
Pacquet parsed license options directly after `pnpm licenses`, so the documented `list` and `ls` subcommands were rejected. Accept those subcommands and report the same missing/unknown-subcommand error codes as the TypeScript CLI.

License discovery also reconstructed the legacy flat virtual-store path. Route it through the shared virtual-store layout instead, preserving lockfile pins and the effective project-selected Node runtime before falling back to the host, and validate package-name components plus slot containment before reading package manifests. This allows license metadata and reported paths to resolve correctly from hashed global virtual-store slots.

Fixes #13332.
Fixes #13333.
The scalar libc regression test covered the string branch added in #13346, while Codecov identified the array and invalid-value branches as uncovered.

Exercise both remaining shapes directly so the parser keeps accepting arrays and rejecting malformed metadata without changing production behavior.

Follow-up to #13346.
Ports the cases from pnpm11/installing/commands/test/update/recursive.ts
and .../update/jsr.ts that the fixture registry can express, closing out
the test-porting half of #12101.

update_recursive.rs covers three behaviors: a versioned selector reaches
only the projects that already declare the package, naming an undeclared
package fails with NO_PACKAGE_IN_DEPENDENCIES and adds it nowhere, and a
dependency aliased onto a workspace package keeps its specifier and stays
linked.

update_jsr.rs asserts the half pacquet already satisfies -- a plain jsr:
dependency resolves and is recorded in the importer -- and gates the rest
behind allow_known_failure! for two real gaps found while porting:
pacquet's jsr specifier parser produces no normalized bare specifier, so
`update --latest` leaves the version untouched (#13363), and an
aliased jsr: dependency resolves into packages and snapshots but never
reaches the lockfile importer (#13362).

The upstream cases left unported drive the `latest` tag around mid-test
with addDistTag; the fixture registry serves `latest` as the highest
published version with no per-run override. TEST_PORTING.md records each
port and why the remainder stays blocked.
@pull pull Bot locked and limited conversation to collaborators Jul 25, 2026
@pull pull Bot added the ⤵️ pull label Jul 25, 2026
@pull
pull Bot merged commit d01230b into dwongdev:main Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant