You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d11dbb5
Browse filesBrowse the repository at this point in the historyBrowse files
Say what the offline commands and the in-memory engine do not see
Two limits of the pnpm registry route in a Bazel workspace were true
of the code and missing from the docs.
repair, scan --prune without a mode, rollback and remove read no Bazel
file. Under a hub whose data lists a pnpm-workspace.yaml that a routed
scan created, they still delete that file with the last of the route,
and the build is then handed a missing file. The docs now say so where
those commands are described, with the way round it.
The route is taken "only where it is certain that no hub reads the
lock". In memory that is certain of the files the engine was handed,
and a Bazel root above the project is not among them, for the route as
for the pin. The docs and the module docs say that beside the claim.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: crates/socket-patch-cli/CLI_CONTRACT.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,7 +335,7 @@ The declaration is what pnpm verifies the lock entries against; the override is
335
335
336
336
The route is taken only when **all** of these hold; otherwise the run takes the `trustLockfile` path below with the locks in the plain shape (a lock half routed would fail to install): (1) the project's own root file is the one pnpm reads (not a workspace member whose settings live in an ancestor file, #880), every governing lock is lockfileVersion 9 (Rush and legacy locks keep their own guidance); (2) every Socket-hosted tarball the governing locks record after the run has a registry: this run was granted it **with** a registry address, or an earlier run routed it, this run was **not** granted it, and the files still route it (the lock keys the release by a registry of the CLI's, the workspace file has its override to that registry, and the registry's address is the directory the tarball is served from). So a run granted only part of the project's patches (a scan of one subtree of a monorepo with one root lock, a search that lists fewer patches than the lock pins) leaves the rest routed and rewrites nothing for them. A pin this run was granted **without** an address is never kept that way (the grant overrules the files), and neither is an ungranted pin the files do not route: either one puts the whole lock on `trustLockfile` and is named. A pin on a patch mirror (`--patch-mirror-url`, experimental) has no address either, whatever its grant carries: see "Patch mirror (experimental)". A tarball is Socket-hosted when this run pinned it or its URL has the patch server's path shape, and every other tarball is the user's own; (3) every pnpm pin of the project (the sources of the #734 rule below, at least one present) proves pnpm 11.20 or newer: the lowest version it admits is 11.20 or higher (`11.28.13`, `^11.20.0`, `>=11.20`, `12`, `>=12`, `12 || 13`, `11.20.0 - 13.0.0`; `>` is read as `>=`, so `>11.19` proves nothing), since older releases write another lock for the same override; a range that reaches below it (`>=11`, `^11`), one the CLI cannot read, or pins that disagree prove nothing; (4) the workspace file can be read, is not a keyless file beside a lock that lists workspace members (#1096), and is a shape a line splice can extend (not a flow-style or indented root, several documents, a `namedRegistries` or `overrides` value on one line, a repeated key, an entry that is not a one-line `key: value`); (5) no override of the user's targets a patched package, by any selector (`<name>`, `<name>@<range>`, `<parent>><name>`): pnpm applies one override per dependency, so the CLI's would lose to it or displace it, and the user's is never overwritten. It is looked for in pnpm-workspace.yaml, the one place the gated pnpm releases read overrides from (`pnpm.overrides` and `resolutions` in package.json are not read by pnpm 11.20 and later, measured through 12.22.0); (6) each lock is one the rewrite was captured against: the release is not a `pnpm patch` copy or an npm alias, an importer that depends on it asks through a plain semver range that admits it (not a tag, `catalog:`, `workspace:`, `npm:` or a URL), no importer locks another version of the package through a range that admits the patched one, no package is installed both with and without the release as its peer (pnpm 11 and 12 lock that differently), the release is not installed as another package's optional peer (pnpm resolves that copy around an override, so it would stay unpatched), and every entry of the lock is one run of lines (a `deprecated:` message of several paragraphs, or one that keeps its trailing line breaks, is written with empty lines inside its entry; a message of several lines without one is a block the routed entry simply loses); (7) no package version is pinned to two patches (an override routes a package version to one registry, and a registry serves one patch); (8) `--no-trust-lockfile-config` is not set, or the file already holds the route exactly; (9) in a Bazel workspace, it is certain that no rules_js hub reads a governing lock. One reads it when an `npm.npm_translate_lock` call of aspect_rules_js names it in a plain string, or has a `pnpm_lock` that is not written out as one, whatever else the call says. And one may read it wherever the workspace was not read whole: a file that `MODULE.bazel` includes and that is missing or unreadable, a use of the extension that is not a plain call of a tag, a `WORKSPACE` file that cannot be read or that brings in rules_js (a `load` from `@aspect_rules_js`, a `load` of `npm_translate_lock` from anywhere, or a call of that rule under any name a `load` gives it). A `WORKSPACE` file that is about something else, an `http_archive` of another ruleset say, defines no hub of a pnpm lock and blocks nothing (see "In a Bazel workspace" below). The write respects `--dry-run` and is refused through a symlink.
337
337
338
-
**In a Bazel workspace.** The lock reader of rules_js takes a routed lock (measured on macOS: rules_js 3.6.0 on Bazel 9.3.2 builds one for a hub without `update_pnpm_lock`, and the built packages hold the patched bytes; rules_js 2.9.3 on Bazel 8.8.2 does too). What holds the route back is the pnpm a hub runs with `update_pnpm_lock`: it sees pnpm-workspace.yaml only where the call lists it, and may be older than pnpm 11.20 (rules_js picks a pnpm 10 where the workspace states none). Run as the hub runs it (`pnpm install --lockfile-only` beside the lock and `package.json`, without the workspace file), pnpm 11.28.13 and 12.22.0 reject a routed lock (`ERR_PNPM_MISSING_NAMED_REGISTRY`, measured). No Bazel leg builds a routed lock with `update_pnpm_lock` yet, so for now every lock that a hub reads is pinned as on a patch service that offers no registry, the files byte for byte, which is the pin the Bazel legs build, and the warning names the call ("… because a Bazel hub reads the pnpm lock (MODULE.bazel:7), and a lock that a hub reads is not routed yet …"; for a project below the Bazel root, "(MODULE.bazel:7, with paths from the root of the Bazel workspace)"); a project routed before the hub was there leaves the route whole on its next scan, the locks and the workspace file together. Under such a hub a hosted scan never deletes pnpm-workspace.yaml, whose label the hub's `data` may name: where the last of a route leaves a file that a routed run created, the file stays as its `packages` list (`packages:` and `- '.'`), and the entries go as elsewhere. Where the hub also hides pnpm-workspace.yaml from a pnpm 11 (`redirect_pnpm_bazel_workspace_hidden`), that answer comes first, while the files are read, and the root lock is not part of the run: nothing in it is pinned or routed, the members' own locks of a workspace with `sharedWorkspaceLockfile: false` are pinned on `trustLockfile`, and a route an earlier run set up is left exactly as it is, in the workspace file and in every lock, because the root lock records the same overrides and is not written. The workspace file is then byte for byte the one it was: the registries still verify the routed releases, so no `trustLockfile: true` is added for them (it would switch the verification off for every entry). Only a release this run pins in the plain shape beside them, in a member's lock, brings the key. A hosted scan takes no unused entry out there either, and what it does to the files does not turn on what it was granted: with a patch for a package of the lock, with none, and with nothing crawled, it leaves the lock and the workspace file as they are and reports `redirect_pnpm_bazel_workspace_hidden` (a run with no npm patch reports it only for a project that holds something of a route; any other project it leaves without a word, as before). The commands that settle a route from the lockfiles alone pin nothing and work as without Bazel: `repair`, `scan --prune` with no mode, `rollback` and `remove`. A pnpm-workspace.yaml that holds nothing but a route and that a hub lists is one of the files `redirect_pnpm_bazel_workspace_hidden` asks for a comment line in: the scan that leaves the route would otherwise leave a file that `rollback` removes.
338
+
**In a Bazel workspace.** The lock reader of rules_js takes a routed lock (measured on macOS: rules_js 3.6.0 on Bazel 9.3.2 builds one for a hub without `update_pnpm_lock`, and the built packages hold the patched bytes; rules_js 2.9.3 on Bazel 8.8.2 does too). What holds the route back is the pnpm a hub runs with `update_pnpm_lock`: it sees pnpm-workspace.yaml only where the call lists it, and may be older than pnpm 11.20 (rules_js picks a pnpm 10 where the workspace states none). Run as the hub runs it (`pnpm install --lockfile-only` beside the lock and `package.json`, without the workspace file), pnpm 11.28.13 and 12.22.0 reject a routed lock (`ERR_PNPM_MISSING_NAMED_REGISTRY`, measured). No Bazel leg builds a routed lock with `update_pnpm_lock` yet, so for now every lock that a hub reads is pinned as on a patch service that offers no registry, the files byte for byte, which is the pin the Bazel legs build, and the warning names the call ("… because a Bazel hub reads the pnpm lock (MODULE.bazel:7), and a lock that a hub reads is not routed yet …"; for a project below the Bazel root, "(MODULE.bazel:7, with paths from the root of the Bazel workspace)"); a project routed before the hub was there leaves the route whole on its next scan, the locks and the workspace file together. Under such a hub a hosted scan never deletes pnpm-workspace.yaml, whose label the hub's `data` may name: where the last of a route leaves a file that a routed run created, the file stays as its `packages` list (`packages:` and `- '.'`), and the entries go as elsewhere. Where the hub also hides pnpm-workspace.yaml from a pnpm 11 (`redirect_pnpm_bazel_workspace_hidden`), that answer comes first, while the files are read, and the root lock is not part of the run: nothing in it is pinned or routed, the members' own locks of a workspace with `sharedWorkspaceLockfile: false` are pinned on `trustLockfile`, and a route an earlier run set up is left exactly as it is, in the workspace file and in every lock, because the root lock records the same overrides and is not written. The workspace file is then byte for byte the one it was: the registries still verify the routed releases, so no `trustLockfile: true` is added for them (it would switch the verification off for every entry). Only a release this run pins in the plain shape beside them, in a member's lock, brings the key. A hosted scan takes no unused entry out there either, and what it does to the files does not turn on what it was granted: with a patch for a package of the lock, with none, and with nothing crawled, it leaves the lock and the workspace file as they are and reports `redirect_pnpm_bazel_workspace_hidden` (a run with no npm patch reports it only for a project that holds something of a route; any other project it leaves without a word, as before). The commands that settle a route from the lockfiles alone pin nothing and work as without Bazel: `repair`, `scan --prune` with no mode, `rollback` and `remove`. **They read no Bazel file**, on this route as for every other hosted pin. So under a hub whose `data` lists a pnpm-workspace.yaml that a routed run created, they still delete that file with the last of the route (as `rollback` deletes a `trustLockfile` file hosted mode created), and the build is then handed a missing file. A hosted scan says so before it comes to that (`redirect_pnpm_bazel_workspace_hidden` asks for a comment line in such a file) and never deletes the file itself. **In memory**, "certain" is certain of the files the engine was handed: the Bazel files at the project's own root (`MODULE.bazel`, the `*.MODULE.bazel` files it can include and the `WORKSPACE` files, beside a `pnpm-lock.yaml` or a `pnpm-workspace.yaml`). A Bazel root above the project is not seen there, for the route as for the pin, so a project in a directory of a Bazel workspace is routed in memory where a checkout is not. A pnpm-workspace.yaml that holds nothing but a route and that a hub lists is one of the files `redirect_pnpm_bazel_workspace_hidden` asks for a comment line in: the scan that leaves the route would otherwise leave a file that `rollback` removes.
339
339
340
340
**What the warning says.** A patch service that gives no pin of the project a registry address offers no route, and the run and its warning are exactly what they were. As soon as one pin has an address, a run that still ends on `trustLockfile` says why, in one sentence of the `redirect_pnpm_trust_lockfile` warning ("Per-package registry verification was not set up because …"): the hosted packages the patch service gave no address for, by `name@version` (the first five, then "and N more"), since one of them puts the whole lock on `trustLockfile`; the hosted packages pinned on a patch mirror, named the same way; pins that do not prove pnpm 11.20; a Bazel hub that reads the lock (9), by the file and line of its call, or what of the Bazel workspace was not read so that one may ("… because a Bazel hub may read the pnpm lock (WORKSPACE:3: it brings in rules_js, and a hub that this file defines is not read) …"); and whichever of (4) to (7) applied, naming the file, the override or the lock entry. With no pnpm pin at all (and not under `--no-trust-lockfile-config`) the sentence is instead that pinning pnpm 11.20 or later (for example with package.json `packageManager`) and re-running the scan switches the project to per-package registry verification. On the route the warning's detail says the file declares the patch server's registry of each patched package (the `socket-<id>` entries, one per patch) and routes each patched release to its own, to commit it alongside the lock, and keeps the rebuild-the-lockfile and clean-reinstall cautions; it carries no whole-lock tradeoff note. **A newer release in range (a note, never a refusal).** An override keyed `<name>@<version>` applies to every dependency whose range admits that version, and a lock records what a transitive dependent resolved, not the range it asked through. So when a governing lock also 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), on the default registry, the detail ends with a note that names the package and both versions: "pnpm-lock.yaml also locks `<name>` at `<other>`, which a range that admits `<version>` may admit too: a package that depends on `<name>` through such a range moves to the patched `<name>@<version>` the next time pnpm resolves (`pnpm add`, `update`, `dedupe`), …". The lock is written as it is (pnpm installs it frozen, and re-locks it unchanged, until a command resolves the project again: see the [pnpm compatibility notes](../../docs/testing/pnpm-compatibility.md) for what each command does). The note is reported on every run that leaves the project routed, a re-run that changes nothing included (in human mode after the one-line reminder), and changes neither the route nor the exit code.
0 commit comments