Hosted mode changes the locked artifact URL and integrity while keeping the package's name and version. Installing that artifact, verifying its files, recognizing it in an SBOM, and changing an alert's policy/count are separate operations. This repository tests the first two; these tests do not assert Socket dashboard detection or alert resolution.
.github/workflows/pnpm-compatibility.yml runs on pull requests and pushes to
main. It compiles the CLI/test once, installs the exact package-manager
versions below, and treats missing tools and failed fixture installs as errors.
The matrix needs no Socket API token. The package managers are real; patch
discovery and tarball endpoints are local test servers.
| pnpm versions | Node | Lock format |
|---|---|---|
| 1.0.0 | 10.24.1 | Expected refusal: shrinkwrapVersion 3 without a minor version discards hosted URLs |
| 1.43.1, 2.0.0, 2.25.7 | 10.24.1 | shrinkwrapVersion 3 with a minor version, shrinkwrap.yaml, block resolutions |
| 3.0.0, 3.8.1 | 10.24.1 | 5.1, block resolutions |
| 4.0.0, 4.14.4, 5.0.0, 5.18.11 | 16.20.2 | 5.1 / 5.2, block resolutions |
| 6.0.0, 6.35.1 | 16.20.2 | 5.3 |
| 7.0.0, 7.33.7 | 16.20.2 | 5.4 |
| 8.0.0, 8.15.9 | 16.20.2 | 6.0, per-peer package resolutions |
| 9.0.0, 9.15.9 | 24.11.1 | 9.0, packages/snapshots split |
| 10.0.0, 10.33.0, 10.34.5 | 24.11.1 | 9.0 |
| 11.0.0, 11.0.3, 11.27.0, 11.29.0, 12.0.0, 12.4.2, 12.25.1 | 24.11.1 | 9.0, hosted URLs require lockfile trust or the registry route |
This samples each released major from 1 through 12 and important major
boundaries; it is not an exhaustive test of every historical patch release or
future release. Pre-lockfile releases cannot use hosted lockfile redirection.
Vendored mode has a separate compatibility contract in docs/ecosystems.md.
The 27 supported versions exercise scan and explicit-UUID hosted entry points, idempotency, warm installs, verified VEX, a clean reinstall, a fresh frozen install with a dead registry and empty store, an ordinary install, byte-exact rollback, lock-only discovery, and rejection of tampered hosted tarballs. pnpm >=6 also gets a local-registry workspace fixture with a scoped package, an npm alias, two peer contexts, and peer dependencies of peers. Legacy workspace behavior before pnpm 6 is not covered by that fixture.
The remaining row, pnpm 1.0.0, verifies an explicit refusal with the lockfile unchanged and no successful redirect recorded. Its installer removes the hosted URL even on a frozen install. For early shrinkwrapVersion 3 locks with no positive minor version, upgrade to a tested release (1.43.1 or newer) and regenerate the lock before redirecting, or use installed-file agent mode.
The same matrix runs the vendored suite (e2e_vendor_pnpm_build) on each
version. One of its cells puts the lock back as it was while the overrides
stay, lets a plain pnpm install write the lock again, and expects vex to
attest once more. pnpm 11.0.0 to 11.0.2 are the exception: they write the
entry of a file: tarball without its tarball (measured: 11.0.2 drops it,
11.0.3 keeps it, as do 9.0.0 to 10.34.9 and 12.0.0 on). A frozen install of
that lock from an empty store then fails (ERR_PNPM_TARBALL_INTEGRITY online,
no tarball offline), so the cell expects vex to omit the patch as
vendor_unwired there, and the matrix pins 11.0.0 and 11.0.3 as the two sides
of the boundary. The lock reader takes such an entry for the vendored one
it is (by its key, with an integrity and no tarball), not for a file:
directory of the user's: the patch is not attested, scan --prune keeps
it, and running the scan again writes the entry back. Before that, a prune
on a checkout with no installed tree reverted the patch.
Captured locks under crates/socket-patch-core/tests/fixtures/pnpm-hosted/
keep grammar coverage in ordinary offline tests. Additional tests cover
LF/CRLF, nested peer suffixes, quoted keys and URLs, unrelated versions,
malformed mappings, and refusal across multiple locks. A CLI regression test
ensures a hosted URL in one instance cannot confirm a partially patched package.
On pnpm 11.20 and newer, hosted mode can have pnpm verify the patched entries
instead of trusting the whole lock. When the patch service gives every hosted
pin a registry address (the directory the patch's tarball is served from) and
every pnpm pin of the project proves pnpm 11.20 or newer, the scan declares
one registry per patch under namedRegistries in pnpm-workspace.yaml
(socket-<first digits of the patch UUID>), routes each patched release to
its own under overrides, rewrites pnpm-lock.yaml to the shape pnpm writes
for that, and writes no trustLockfile (see docs/ecosystems.md). The matrix
above installs through trustLockfile: its fixture grants carry no registry
address.
pnpm verifies a lock entry against a declared registry from 11.10 on, and frozen installs pass with a declaration alone on every release from 11.10.0 through 12.22.0. A declaration does not survive a command that resolves again, though: pnpm asks the default registry and puts the upstream tarball back. Measured on a lock with hosted entries, with the registry only declared:
| pnpm | pnpm add of another package |
pnpm update, pnpm dedupe, install --fix-lockfile |
|---|---|---|
| 11.10.0, 11.20.0, 11.25.0, 11.28.13 | hosted entries re-resolved to the upstream tarball | hosted entries re-resolved |
| 12.0.0, 12.4.2, 12.10.0, 12.16.0 | hosted entries kept | hosted entries re-resolved |
| 12.19.0, 12.21.0, 12.22.0 | kept, except a hosted package with peer dependencies in its subtree (its own, or a dependency's), which is re-resolved | hosted entries re-resolved |
(trustLockfile: true keeps hosted entries across pnpm add on 11.28.13 and
12.x, and loses them on 11.10.0 through 11.25.0.)
With '<name>@<version>': 'socket-<id>:<version>' beside the declaration of
the patch's registry socket-<id>, pnpm resolves the package from that
registry every time. Measured with real pnpm against a stand-in patch server
that serves one registry per patch, for packages with and without peer
dependencies:
| pnpm | lock written for the routed project | fresh-store frozen install | pnpm add |
pnpm update |
pnpm dedupe |
install --fix-lockfile |
|---|---|---|---|---|---|---|
| 11.10.0, 11.15.0 | another lock | |||||
| 11.20.0, 11.25.0, 11.28.13 | byte-identical | passes | kept | kept | kept | kept |
| 12.0.0 | byte-identical | passes | kept | kept | kept | this release has no such flag |
| 12.4.2, 12.10.0, 12.16.0, 12.19.0, 12.21.0, 12.22.0 | byte-identical | passes | kept | kept | kept | kept |
"Byte-identical" is across these releases and with the lock the scan writes:
the golden fixtures under
crates/socket-patch-core/tests/fixtures/pnpm-registry-overrides/ hold, for
each project shape, the lock real pnpm resolves once the workspace file routes
the patches, and the scan must write the same bytes. They were generated with
pnpm 12.22.0 and are identical on 11.20.0, 11.25.0, 11.28.13, 12.0.0, 12.4.2,
12.10.0, 12.16.0, 12.19.0 and 12.21.0 (scripts/gen-pnpm-registry-override-golden.mjs
regenerates them and fails when two releases disagree). They cover a
transitive leaf, a scoped direct dependency, a package with its own peer
dependencies, a package under a peer-suffixed parent, a patched package that
is itself a peer, both at once, two versions of one package (one or both
patched), several importers, members with their own locks
(sharedWorkspaceLockfile: false, where every lock records the overrides), a
project with overrides of its own, a project with registries of its own named
socket and with the very name a patch's registry would take (the patch's
then takes four more digits), two patches whose UUIDs start with the same
eight digits, several patches at once, a patched release whose upstream
deprecation message spans several lines, and pnpm 12's two-document lock.
pnpm locks a deprecation message of several lines as a block scalar
(deprecated: |- and the message's lines, more deeply indented), and the
routed entry carries none of it: the patch server's registry document has no
deprecated. A message of several paragraphs is locked with an empty line
inside the entry (deprecated: |), and one that ends in line breaks keeps
them (deprecated: |+). The scan's lock edits move an entry as one run of
lines, so a lock that holds either is kept on trustLockfile, with that
reason.
Two shapes are in the fixtures as refusals, because pnpm does not lock them as
a respelling of the plain lock; the scan keeps such a project on
trustLockfile and says why:
- a package installed both with and without the patched release as its peer
(two importers resolving the peer differently): pnpm 12 records no
version:line for that package, pnpm 11 does; - the patched release installed as another package's optional peer: pnpm resolves the copy of an importer that does not depend on the release directly from the default registry, around the override, so that copy would stay unpatched.
One consequence of the override is pnpm's own: <name>@<version> matches every
dependency range that admits that version, so a dependent that had resolved a
newer version through such a range moves to the patched one the next time pnpm
resolves. The scan refuses the route when an importer of the project is in that
position (the lock records importers' ranges); for transitive dependents the
lock does not record the range, and the lock the scan writes is what pnpm
installs frozen.
Measured with real pnpm on a project where one package depends on leaf at
exactly 1.0.0 (patched) and another through ^1.0.0, locked on 1.5.0. The
scan routes leaf@1.0.0, leaves the other dependent on 1.5.0, and notes
that the lock also holds 1.5.0 in range. Then:
| pnpm | frozen install, pnpm install, install --lockfile-only |
pnpm add <another package> |
pnpm update, pnpm dedupe |
|---|---|---|---|
| 11.20.0, 11.25.0, 11.28.13 | the scan's lock, byte for byte; the dependent keeps 1.5.0 | the dependent moves to the patched 1.0.0 | the dependent moves to the patched 1.0.0 |
| 12.0.0, 12.4.2, 12.10.0, 12.16.0, 12.19.0, 12.21.0, 12.22.0 | the scan's lock, byte for byte; the dependent keeps 1.5.0 | the dependent keeps 1.5.0 | the dependent moves to the patched 1.0.0 |
So the lock the scan writes is not the one pnpm writes the next time it
resolves the whole project: leaf@1.5.0 leaves the lock and its dependent
installs the patched 1.0.0. The routed release itself is kept in every case.
The scan does not refuse the route for this (the range is not in the lock to
check); it names the package and both versions in a note of its pnpm guidance
whenever a governing lock holds a newer release of a routed package within the
routed release's caret range (the same major, or the same minor below 1.0).
The route is refused when the user overrides a patched package, and the scan
looks for such an override in pnpm-workspace.yaml. That is the only place
the gated releases read one from. Measured on pnpm 11.20.0, 11.25.0, 11.28.13,
12.0.0, 12.4.2, 12.10.0, 12.16.0, 12.19.0, 12.21.0 and 12.22.0: pnpm.overrides
in package.json is ignored with a warning ("The "pnpm" field in package.json is
no longer read by pnpm"), resolutions is ignored silently, the lock records no
overrides: for either, and the dependency resolves as without them.
A pin proves pnpm 11.20 when the lowest version it admits is 11.20 or higher
(11.28.13, ^11.20.0, >=12, 12 || 13); >=11, an unreadable range, pins
that disagree, or no pin leave the project on trustLockfile. With no pin at
all, and a registry address for every hosted pin, the warning adds that
pinning pnpm 11.20 or later (for example with packageManager) and re-running
the scan switches the project over.
The registry's version documents are dated by the upstream release of the
version, or carry no date when it is unknown, so pnpm's default one-day
minimumReleaseAge does not hold back a freshly published patch.
pnpm reads a build decision for a routed release from allowBuilds in
pnpm-workspace.yaml alone, and which key approves it depends on the major.
Measured with a routed package that has a postinstall script, a frozen
install from an empty store each time:
allowBuilds |
pnpm 11.20.0, 11.29.0 | pnpm 12.0.0, 12.25.1 |
|---|---|---|
pkg: true |
installs, script runs | ERR_PNPM_IGNORED_BUILDS |
'pkg@<version>': true |
installs, script runs | ERR_PNPM_IGNORED_BUILDS |
pkg: true and 'pkg@socket-<id>:<version>': true |
ERR_PNPM_INVALID_VERSION_UNION |
installs, script runs |
'pkg@socket-<id>:<version>': true alone |
ERR_PNPM_INVALID_VERSION_UNION |
installs, script runs |
pkg: false |
installs, script skipped | installs, script skipped |
pkg: false and 'pkg@socket-<id>:<version>': true |
not measured | installs, script skipped (12.25.1) |
| no entry | ERR_PNPM_IGNORED_BUILDS |
ERR_PNPM_IGNORED_BUILDS |
A key with a * is no pattern: '*': true and 'pkg*': true approve nothing
on 11.29.0 or 12.25.1, routed or not (the install fails as with no entry).
onlyBuiltDependencies in the workspace file, and pnpm.allowBuilds or
pnpm.onlyBuiltDependencies in package.json, decide nothing on any of the
four (11.29.0 and 12.25.1 measured): the install fails as with no entry. A
key under the id whose registry the file no longer declares, in a project that
is not routed, changes nothing on pnpm 12.25.1. A comment after an entry is
read as YAML reads it, and pnpm 12.25.1 keeps it when it rewrites the file:
after pnpm add of a package with an unapproved script and
pnpm approve-builds --all, which adds the package's entry and sorts the map,
the line the scan added still ends in its comment.
So an approval is repeated under the id only where the pins package.json
commits prove pnpm 12 or newer, nothing is added where they prove pnpm 11,
and a project whose approval no committed pin places stays on
trustLockfile, which installs and runs the script on both majors (11.29.0
and 12.25.1 measured). The pnpm that last installed node_modules is not
proof here: a key written for it fails every install on the other major.
A routed lock needs the pnpm-workspace.yaml that declares its registries. Measured with
pnpm 11.28.13 and 12.22.0: pnpm install --lockfile-only in a directory that holds the
routed lock and package.json and no workspace file fails with
ERR_PNPM_MISSING_NAMED_REGISTRY ("has registry prefix 'socket-…:', which is not declared
by the registries setting") and leaves the lock as it is. That directory is what a
rules_js hub of a Bazel workspace gives the pnpm it runs for update_pnpm_lock when the
hub does not list the file, and a build of such a hub fails the same way (pnpm 11.28.10,
rules_js 3.6.0 on Bazel 9.3.2, 8.8.2 and 7.7.2). The lock reader of rules_js itself takes
a routed lock: on those three releases rules_js 3.6.0 builds one for a hub without
update_pnpm_lock, with the patched bytes in the built packages (and, measured by hand,
rules_js 2.9.3 on Bazel 8.8.2 does too). So does a hub with update_pnpm_lock that lists
the file and runs pnpm 11.20.0, 11.28.10 or 12.17.0: that pnpm writes the lock back as it
is, also after a package.json asks for another package. A pnpm below 11.20 does not
survive that change: pnpm 11.19.0 puts the upstream release back and pnpm 10.34.9 fails
(ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER). And a routed lock holds the patched
release under another version, so a patches entry of the hub that is keyed by the
package's name and version names no package of it, and rules_js fails the build (measured
on the three releases). The scan therefore takes the route for a lock that a hub reads in
those two shapes of the hub alone, and only where the call of the hub passes nothing but
the attributes those builds had (see "Bazel workspaces: npm" in
ecosystems).
pnpm12_registry_route_survives_resolution_and_cleans_up and its pnpm 11
twin run with the other real-pnpm legs of e2e_redirect_pnpm_build, on the
pnpm 12 and pnpm 11 that Corepack provides, with no network beyond two
loopback servers (a default registry of synthetic packages, and the patch
server on its own origin, since pnpm keys its metadata cache by host). Over a
project with a peer-dependent package and a transitive leaf, both patched,
each leg checks that pnpm install --lockfile-only leaves the scan's lock
byte for byte; that a fresh checkout frozen-installs the patched bytes from an
empty store with no flags, asking each patch's own registry for its package;
that the pnpm install the scan asks for, run over a node_modules that
holds the upstream packages, links the patched entries and keeps the upstream
ones in the store, where vex attests both patches from the linked copies and
refuses a linked copy that is put back on the upstream bytes (see "The install
over an existing node_modules" below);
that pnpm add, pnpm update, pnpm dedupe and pnpm install --fix-lockfile keep both packages routed and patched; and that after each
cleanup (a
rollback of one package, the re-scan that routes it again, the fall back to
trustLockfile when a grant loses its address, a full rollback) a frozen
install from an empty store still accepts the workspace file and the lock
together.
pnpm12_registry_route_reaches_a_newer_release_in_range and its pnpm 11 twin
pin the two measurements above: what each pnpm command does with a newer
release in range of a routed one, and that an override in package.json reaches
no lock.
pnpm12_registry_route_is_left_for_a_bazel_hub_added_later and its pnpm 11
twin route a project, add a rules_js hub to its MODULE.bazel and scan again,
with no Bazel. Where the hub keeps the lock up to date with a pnpm 11 that
does not see the workspace file, the scan changes neither file; where the hub
keeps it up to date with a pnpm 10 that is shown the file, the scan takes the
registry, the override, the lock's record and the registry keys out in one run
and pins the release on trustLockfile. A fresh checkout frozen-installs the
patched bytes from an empty store after either. (A hub that only reads the
lock keeps the route now.)
pnpm12_registry_route_is_cleaned_up_when_a_patch_is_not_needed and its pnpm
11 twin run in the same suite, against the same two loopback servers. They
check out the routed project once per case, change it with the real pnpm the
way a user would, and run the command that cleans up: the dependency removed
(pnpm remove), then scan, repair --offline and scan --prune each; the
dependency upgraded past the patched release (pnpm add <name>@2.0.0), then
scan and repair --offline each; every patched dependency removed, then
scan and repair --offline each; the patch of one package withdrawn, then of
both, then scan. Each command first runs with --dry-run, which must leave
pnpm-workspace.yaml and the lock byte for byte. After each wet run the two
files are compared with what is expected, pnpm install --lockfile-only
re-locks them without changing a byte, and a fresh checkout installs with
--frozen-lockfile from an empty store. scan, repair and scan --prune
must leave the same bytes; repair runs with no patch service to reach.
Offline tests cover the workspace-file edit
(formats::pnpm::named_registries), the lock rewrite against the golden
fixtures (formats::pnpm::registry_alias), the choice between the two
settings and every cleanup (hosted::engine), the cleanup repair and a
--prune pass run from the files alone
(patch::redirect::upstream::route_sweep_tests), the scan, rollback,
remove and the vendored takeover end to end (in_process_redirect_pnpm,
in_process_vendor_pnpm_takeover), and each command's cleanup of unused
registry entries, with its dry run and its JSON report
(in_process_pnpm_registry_cleanup).
scan --mode hosted changes lockfiles; it does not replace already installed
files. Several pnpm versions reuse the original files from an existing install
or store even when installation succeeds. --force alone is not portable and
can re-resolve upstream artifacts on pnpm 12.
For CI, install the patched branch in a clean checkout without any
node_modules directories, using a new empty store for the post-patch install:
pnpm install --frozen-lockfile --store-dir "$RUNNER_TEMP/socket-patch-store-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
socket-patch vex --output socket-patches.openvex.jsonThe store path must be empty and must not be restored from a cache. On pnpm
1–4 use --store; pnpm 1–3 can silently ignore --store-dir, and early pnpm 4
rejects it. For a workspace, the clean checkout requirement includes
member node_modules trees. Keep the redirected lockfile and any generated
pnpm-workspace.yaml; do not delete or regenerate the lock to work around an
installation error. VEX uses installed-file verification by default; exporting
VEX does not automatically upload it or change Socket alert counts.
A generated pnpm-workspace.yaml (packages: ['.'] plus trustLockfile: true,
the hosted namedRegistries: and overrides:, or the vendored overrides:)
makes a
single-package project a root-only workspace. pnpm 9.0.0–10.4.x then refuse
pnpm add <pkg> with
ERR_PNPM_ADDING_TO_ROOT unless given -w; 10.5.0 and later add normally. So
neither mode creates the file when every pnpm pin of the project (the
node_modules/.modules.yaml install record, package.json packageManager,
devEngines.packageManager, engines.pnpm) names 9.0–10.4, which read neither
setting from it. With no pin, or any pin that may be a later pnpm, the file is
created as before.
On the registry route, and in vendored mode on every pnpm, the patched
release has another lock key than the upstream one, so pnpm installs it as
another entry of its virtual store. Measured with pnpm 12.25.1 and 11.29.0
(both modes) and 10.34.9, 9.15.9 and 8.15.9 (vendored): pnpm install over a
node_modules that holds the upstream package links the project (the
importer, the hoist directory, each dependent's entry) to
node_modules/.pnpm/<name>@socket-<id>+<version> or <name>@file+… (file+…
on pnpm 8), and leaves node_modules/.pnpm/<name>@<version> in the store with the upstream
bytes and nothing linking to it. pnpm 7–11 remove such an entry after 7 days,
pnpm 12 on pnpm prune. With trustLockfile the lock key stays, and pnpm
keeps the one entry.
When the patched package is a peer dependency of another package, the
registry route gives the dependent a new entry as well
(<dependent>_<name>@socket-<id>+<version>), and the dependent's old entry
keeps its link to the old <name>@<version> entry (pnpm 11.29.0 and
12.25.1). Vendored mode keeps the dependent's entry and points its link at
the new one (pnpm 8.15.9, 9.15.9, 10.34.9 and 12.25.1).
pnpm writes the path of a store entry into .bin launchers: 12.25.1 into
each one, 11.29.0 into those inside a dependent's own node_modules (the
importer's and the hoist directory's go through the package link beside
them, as on pnpm 8.15.9, 9.15.9 and 10.34.9). The install rewrites them.
Measured with a patched package that ships a command and has a dependent
(json5@1.0.1), in a single project and a workspace, hosted and vendored,
on 11.29.0 and 12.25.1: after the install the only file that names the
upstream entry's directory is the launcher inside that entry itself.
vex and apply --check judge the copies the install links. For a package
version that sits in two entries of one store with other bytes in each
they read every link below the scanned directory, and leave out an entry that no path from outside
the store's entries leads into (see "npm: which node_modules trees are
crawled" in ecosystems for the rule and for the layouts
where every entry is still judged). There the upstream
entry reads as an unpatched copy until it is gone: vex omits a hosted
patch as not_applied, or warns vendored_tree_out_of_sync for a vendored
one. pnpm prune removes the entry at once (measured on 11.29.0 and
12.25.1, on the registry route), and a clean node_modules has no such
entry.
A link that leads out of the scanned directory is followed. Measured in a
Bazel 9.3.2 workspace that links about 1,200 packages with aspect_rules_js
3.6.0: the bazel-bin, bazel-out, bazel-testlogs and bazel-<name>
links lead into the output tree, which holds about 7,000 directories and
6,700 links, and from there into the contents of the external repositories
(about 9,200 directories). After a vendored scan and the pnpm install
over the existing node_modules, vex reads all of it and attests without
a warning; a link to the upstream entry in bazel-bin, in an external
repository's contents, or in a node_modules above the output tree's
workspace directory brings the warning back.
Windows is judged the same way, but for a link that leads out of the
scanned directory to a directory: it is not followed there, and keeps
every entry. Measured with pnpm 11 and 12 on a windows-latest CI runner,
on the registry route, in the workspace of the
*_in_place_install_is_judged_by_every_link legs below:
- The install leaves the same entries.
leaf@1.0.0stays besideleaf@socket-<id>+1.0.0with the upstream bytes, and the old entries of the dependents keep their links to it. The new entry of the peer-dependent tarball package gets a hashed name there (needs-leaf@file+needs-leaf-_<hash>), since pnpm'svirtualStoreDirMaxLengthis shorter on Windows. The rule does not read an entry's name. - pnpm links a directory with a symbolic link where it may make one (on
that runner, with a relative target) and with a junction where it may
not. Both are links to
vex, and no directory there resolves elsewhere without being one. - A real path is spelled
\\?\C:\…, with every short name written out (RUNNER~1asrunneradmin), the same way for the store and for the target of each link, so the two compare. - A launcher is three files (
.bin/<cmd>,<cmd>.cmd,<cmd>.ps1) that hold absolute paths with backslashes. After the install the ones that name the old entry sit inside the old entries, which nothing links.
Read from pnpm's source, not measured: writeModulesManifest of 9.15.9 and
11.27.0 records the virtual store in .modules.yaml by its absolute path
on Windows, and by its path from the modules dir elsewhere. Either way the
record is the store's when the path it names resolves to the store.
Resolving a junction fails with ERROR_FILE_NOT_FOUND when its target is
not there, with ERROR_PATH_NOT_FOUND when a directory on the way to the
target is not there or is a file, and with ERROR_CANT_RESOLVE_FILENAME
when it leads to itself (measured on the same runner, by
test_links_that_lead_nowhere_fail_with_the_errors_read_as_such). Those
three are the links that lead nowhere on Windows, and only when the
target fails the same way when it is asked for by itself: a target on a
volume without a drive letter is there, but has no path to name it by.
Every other failure keeps every entry: access that is denied, a network
path that cannot be reached, a link Windows may not follow. So does a
link whose target names a drive or a share that is not there, whatever
it fails with: a mapped drive is there for one session and not for
another (test_link_into_a_drive_that_is_not_there_does_not_lead_nowhere,
where a junction into such a drive can be made). Not measured: the code
for a junction to a file. The
identity of a file, which tells the store from another spelling of its
path, is the serial number of its volume and its index there, read from
a handle that is opened without access to what the file holds. A
directory above the store is not asked for it.
A workspace with a modulesDir of more than one level is judged from the
workspace's root. Measured with modulesDir: sub/node_modules: pnpm 10.12.1,
10.34.9, 11.29.0 and 12.25.1 put the virtual store in
sub/node_modules/.pnpm and each member's links in
<member>/sub/node_modules; pnpm 9.15.9 and 10.11.1 put the links and the
install record there too, but keep the virtual store in node_modules/.pnpm.
The lockfile in the store names the members from the root either way, and
the root is found through the modulesDir setting of pnpm-workspace.yaml
or .npmrc; the record of the older layout is read from the modules dir and
has to name the store.
The registry-route legs above and the vendored capstone
(e2e_vendor_pnpm_build, on each pnpm of its matrix from 9 up) run that
install in a second checkout and end in vex, with the linked copy patched
and then put back on the upstream bytes; the capstone also links the
upstream entry from vendor/, which brings the warning back. Two more
registry-route legs run the install in a workspace whose patched package is
hoisted and is also the peer dependency of a tarball package
(*_in_place_install_is_judged_by_every_link,
*_in_place_install_under_a_nested_modules_dir): vex
attests both patches; a link to the upstream entry from vendor/, dist/,
a hidden directory or a package's own node_modules refuses the patch
until the link is gone; and under the nested modulesDir both patches are
attested as well, until a link in a member's own modules dir reaches the
upstream entry. Where vex attests, a second reading of the links
(tests/common/pnpm_links.rs, which shares no code with the CLI) checks
that no path from outside the store's entries leads into an entry that
holds the upstream bytes, and where a link was added it must find that
link. Hand-built stores of the same shapes cover the rule offline:
crawlers::npm_crawler (test_pnpm_store_*, test_links_below_*,
test_links_that_lead_nowhere_*), e2e_vex_redirect, e2e_vex_vendor,
the apply --check suite and the rollback suite, which restores an
unlinked entry.
The registry-route legs run on Linux, macOS and Windows. On Windows the
links a leg adds are junctions, beside the symbolic links pnpm writes on
the runner, and the unit tests of crawlers::npm_crawler link their stores
with junctions there (one with symbolic links, as that runner's are). A
case that links a file runs only where a symbolic link to a file can be
made: Windows has no junction to a file, and a symbolic link takes Developer
Mode or an elevated process. The cases that take a directory away with
chmod, link a named pipe, or spell a path through macOS's
/System/Volumes/Data do not run on Windows. The vendored capstone has
no leg on the Windows runner, and its in-place steps are skipped on
Windows until it has one.
cargo test -p socket-patch-core --test pnpm_hosted --test redirect_golden
cargo test -p socket-patch-cli --test in_process_redirect_pnpm \
--test in_process_pnpm_registry_cleanup
# Provision the chosen pnpm executable and a compatible Node on PATH first.
SOCKET_PATCH_PNPM_E2E_BIN=/absolute/path/to/pnpm \
SOCKET_PATCH_PNPM_E2E_VERSION=10.33.0 \
SOCKET_PATCH_PNPM_E2E_REQUIRED=1 \
cargo test -p socket-patch-cli --test e2e_redirect_pnpm_build \
pnpm_pinned_matrix -- --ignored --nocapture
# Separate production-service proof, with pnpm on PATH; no API token needed.
SOCKET_PATCH_HOSTED_E2E_STRICT=1 \
cargo test -p socket-patch-cli --test e2e_hosted_production \
pnpm_hosted_install_proof -- --ignored --nocaptureThe required test verifies the reported pnpm version. In particular, an unavailable legacy runtime must fail setup rather than remove a matrix row from coverage. Hosted tests isolate package-manager caches and allocate independent empty stores for each installation proof.