From 744a4645b1bad797cfa285e5f9acb8d416ac0d8f Mon Sep 17 00:00:00 2001 From: Mikola Lysenko Date: Fri, 20 Nov 2026 12:23:37 -0500 Subject: [PATCH 1/2] Document what socket-patch supports in a Bazel workspace A Bazel build takes each package from what a ruleset reads in the checkout, in a repository of its own, and not from the copies a package manager installed. The mode by ecosystem matrix at the top of docs/ecosystems.md therefore does not carry over to a project that Bazel builds, and until now the docs had no one place that says what does. Add "Bazel workspaces: what is supported" ahead of the three Bazel sections: one table of ecosystem and ruleset by hosted, vendored, agent and VEX, whose cells say "Supported", "Supported with " or "Not supported". - Hosted and vendored cells are the flows of crates/socket-patch-cli/tests/e2e_bazel_build, which build each shape on Bazel 9.3.2, 8.8.2 and 7.7.2 (Maven also on 7.4.0): hosted for all eight ecosystems, vendored for npm, Go and Cargo. - Agent mode is "Not supported" in every row. It is made for installed copies, which a Bazel build does not use, and the support statement is kept simple: hosted or vendored mode for a package that Bazel builds. - VEX is "Supported" where the document is checked against what Bazel builds (npm, PyPI, RubyGems) and "Supported with a hosted (or vendored) patch" where it is right for a patch of that mode and is not checked against the build. Under the table: the Bazel releases, rulesets and call forms each row was tested with, the stale MODULE.bazel.lock after some commands, and a list of known problems, the cases where a command exits 0 today and the next Bazel build fails (vendored PyPI, RubyGems, NuGet and Composer; a Cargo hub without cargo_config or with a cargo-bazel lock; a NuGet tag without nuget_config; a gem that gem_checksums pins; update_pnpm_lock; vendored Go on an old gazelle), each with what to do instead. The VEX section no longer lists agent mode among the Go flows it calls tested, the .bazelignore section says where agent mode stands, and docs/usage.md points from its agent mode section to the table. Two sentences about a vendored gem now say that its build was measured by hand and that no test runs it yet. No code and no test changes. Co-Authored-By: Claude Fable 5.2 --- docs/ecosystems.md | 154 +++++++++++++++++++++++++++++++++++++++++++-- docs/usage.md | 4 ++ 2 files changed, 152 insertions(+), 6 deletions(-) diff --git a/docs/ecosystems.md b/docs/ecosystems.md index 2c11dd3cf..38851c031 100644 --- a/docs/ecosystems.md +++ b/docs/ecosystems.md @@ -12,6 +12,10 @@ For what the three modes *are* and how to choose between them, see The backticked slug in each row is the value `-e`/`--ecosystems` accepts (e.g. `--ecosystems npm,pypi,golang`). +For a project that Bazel builds, see +[Bazel workspaces: what is supported](#bazel-workspaces-what-is-supported): the table +below is about what a package manager installs and builds. + | Ecosystem | agent (`--mode agent`) | vendored (`--mode vendored`) | hosted (`--mode hosted`) | |-----------|------------------------|------------------------------|--------------------------| | npm (`npm`) — pnpm / yarn / berry / bun / vlt | ✅ any install layout, vlt's `node_modules/.vlt` store included (every store copy, copy-on-write) | ✅ seven lockfile flavors: package-lock, yarn classic, yarn berry (node-modules linker; PnP refused), pnpm v9, pnpm legacy v5.4/v6.0 (`pnpm 7/8` — frozen installs are path-bound because those majors absolutize `file:` override specifiers; moved checkouts run one `pnpm install --offline --no-frozen-lockfile`, surfaced as `vendor_pnpm_legacy_absolute_specifier`), bun text `bun.lock` lockfileVersion 0/1/2/3 and native binary `bun.lockb` revisions 1/2/3 (binary locks stay binary; text workspace vendoring requires lockfileVersion 2 — see [Bun compatibility](testing/bun-compatibility.md)), vlt `vlt-lock.json` lockfileVersion 0/1 (patched package directories for direct dependencies of the root or a workspace member; transitive targets refused — see [vlt notes](#npm-vlt-notes)). Rush monorepos on pnpm 9 and newer are wired through `pnpm-config.json` and each directly-depending project's `package.json` — see [Rush notes](#npm-rush-monorepos) | ✅ package-lock / npm-shrinkwrap, pnpm-lock.yaml and legacy shrinkwrap.yaml (pnpm majors 1–12; block and flow resolutions), yarn classic, yarn berry, bun, vlt (`vlt-lock.json` without `lockfileVersion`, 0 or 1) — pnpm, berry, bun and vlt carry constraints, see [npm hosted-mode notes](#npm-hosted-mode-notes) and [vlt notes](#npm-vlt-notes) | @@ -1767,6 +1771,141 @@ the repository list, so it is left as a (`projectMatrix`, `crossProject`, a computed `Project(...)`). The note names the cause and its remedy. +## Bazel workspaces: what is supported + +A Bazel build takes each package from what a ruleset reads in the checkout (a lock, a call in +`MODULE.bazel`), in a repository of Bazel's own, and not from the copies a package manager +installed. So the [matrix at the top](#mode--ecosystem-matrix) does not carry over to a +project that Bazel builds: this table takes its place there. A project that sits in a Bazel +workspace and that Bazel does not build keeps the matrix at the top. + +| Ecosystem, and how Bazel takes its packages | Hosted | Vendored | Agent | VEX | +|---|---|---|---|---| +| npm: aspect_rules_js `npm.npm_translate_lock` over a pnpm lock | Supported | Supported | Not supported | Supported | +| PyPI: rules_python `pip.parse` over a requirements file | Supported | Not supported | Not supported | Supported | +| Go: gazelle `go_deps.from_file` over `go.mod` | Supported | Supported | Not supported | Supported with a hosted or vendored patch | +| RubyGems: rules_ruby `ruby.bundle_fetch` over `Gemfile.lock` | Supported with no `gem_checksums` on the call | Not supported | Not supported | Supported | +| Cargo: rules_rust `crate.from_cargo` over `Cargo.lock` | Supported with `cargo_config` on the hub | Supported | Not supported | Supported with a hosted or vendored patch | +| NuGet: rules_csharp `nuget.from_lock` over `packages.lock.json` | Supported with `nuget_config` on the tag | Not supported | Not supported | Supported with a hosted patch | +| Composer: a rule of your own that runs `composer install` from `composer.lock` | Supported | Not supported | Not supported | Supported with a hosted patch | +| Maven: rules_jvm_external `maven.install` with a `lock_file` | Supported with Bazel 7.4.0 or later | Not supported | Not supported | Supported with a hosted patch | + +What a cell says: + +- **Supported**, for hosted and vendored mode: after the one command of the mode + (`scan --mode hosted` or `scan --mode vendored`; for Maven + `get --mode hosted` at the Bazel root), the next `bazel build` takes the patched + package with nothing else to do, and the undo (`rollback`, `vendor --revert`) brings the + upstream build back. A test builds exactly that on a real Bazel, for the shape the list + below names. +- **Not supported**: do not use the mode for a package that Bazel builds. The patch does not + reach the build, or the build breaks (see the known problems below). +- **Supported**, for VEX: `socket-patch vex` and `--vex` say `not_affected` of a package the + Bazel build takes patched, and `affected` of one whose patch Bazel does not build. + [Bazel workspaces: VEX](#bazel-workspaces-vex) has the cases and the limits; a vendored gem + is one of the limits. +- **Supported with a hosted (or vendored) patch**, for VEX: the document is right for a patch + that was applied in that mode. It is not checked against what Bazel builds, so of a package + whose patch is in no build of Bazel's (one that is only in an installed copy, say) it still + says `not_affected`. Do not publish that document. + +**Agent mode is not supported for Bazel builds, in any ecosystem.** Agent mode is made for +the copies a package manager installed: `socket-patch apply` patches them after each install. +A Bazel build does not use those copies and runs no such step. Use hosted or vendored mode +for a package that Bazel builds. Agent mode stays what it is for whatever uses the installed +copies outside Bazel. + +What the table was tested with: + +- **Bazel** 9.3.2, 8.8.2 and 7.7.2 on Linux, and 9.3.2 on macOS (not Composer); Maven also + on 7.4.0. Every row is a workspace under Bzlmod (`MODULE.bazel`): nothing is tested for + dependencies that a `WORKSPACE` file declares. +- **npm**: aspect_rules_js 3.6.0, `npm.npm_translate_lock(pnpm_lock = "//:pnpm-lock.yaml")` + without `update_pnpm_lock`, and a lock of `lockfileVersion: '9.0'`. +- **PyPI**: rules_python 2.5.0-rc4, `pip.parse(requirements_lock = "//:requirements.txt")`, + and a root `requirements.txt` with hashes. +- **Go**: gazelle 0.54.0 with rules_go 0.65.0 (Bazel 9 and 8) and gazelle 0.45.0 with + rules_go 0.53.0 (Bazel 7), `go_deps.from_file(go_mod = "//:go.mod")` with + `go_deps.config(check_direct_dependencies = "error")`, and the module required directly in + `go.mod`. Vendored mode keeps its copy out of Bazel's packages with + [`.bazelignore`](#bazel-workspaces-bazelignore). Hosted mode for Go has the limit of the + matrix at the top: free-tier patches. +- **RubyGems**: rules_ruby 1.0.0-rc2, `ruby.bundle_fetch` with `gemfile` and `gemfile_lock` + and no `gem_checksums`, and a `Gemfile.lock` that has a `CHECKSUMS` section. +- **Cargo**: rules_rust 0.75.0 (Bazel 9 and 8) and 0.56.0 (Bazel 7), `crate.from_cargo` with + `cargo_lockfile = "//:Cargo.lock"`, `manifests = ["//:Cargo.toml"]` and + `cargo_config = "//:.cargo/config.toml"`, and no cargo-bazel lock (`lockfile`). +- **NuGet**: rules_csharp 0.5.0, `nuget.from_lock` with + `packages_lock_json = "//:packages.lock.json"` and `nuget_config = "//:nuget.config"`. + `scan` finds a NuGet package only where a restore unpacked it (NuGet's global packages + folder, a folder that an `obj/project.assets.json` records, or a `packages` folder): on a + machine where only Bazel ever ran it finds none, exits 0 and writes nothing. +- **Composer**: no ruleset builds PHP, so the two shapes are rules a project writes itself: a + repository rule that runs `composer install` from the committed `composer.lock` and takes + the lock with `rctx.read`, and a genrule that runs it in a build action. Composer 2 and PHP + are the machine's own. Run the command in the project's directory. A project that commits + its `vendor/` tree for Bazel to read is not one of the two. +- **Maven**: rules_jvm_external 7.2 (Bazel 9), 6.9 (Bazel 8) and 6.5 (Bazel 7), a hub with a + `lock_file`. [Bazel workspaces: Maven](#bazel-workspaces-maven) says what the command + writes and when it declines; `scan` does not find a hub's artifacts yet. + +A ruleset, a release of one or a way of calling it that the list does not name is not tested. +Treat it as not supported until a build after the command has shown you the patched package. + +Bazel's own lock: a command or an undo leaves `MODULE.bazel.lock` stale for PyPI on Bazel 8.5 +and later, for NuGet, and for Cargo under rules_rust 0.75.0. A build that may not update the +lock (`--lockfile_mode=error`) fails until one that may, or +`bazel mod deps --lockfile_mode=update`, has rewritten it. Commit the rewritten lock with the +patch. + +Known problems. In each of these a command exits 0 today and the next Bazel build fails, +unless it says otherwise: + +- **Vendored mode for PyPI, RubyGems, NuGet and Composer.** The path of the committed copy + means nothing where Bazel runs: rules_python takes it for a package name, rules_ruby's + `bundle install` does not find it (`The path ... does not exist`), rules_csharp reads it as + a URL (`Bad URL`, or a crash of Bazel 9.3.2), and a Composer that Bazel runs elsewhere + reports `Source path ... is not found`. Run `socket-patch vendor --revert`, then + `socket-patch scan --mode hosted`. Of these builds a test of this repository runs the PyPI + one; the others were measured by hand on the three Bazel releases. +- **Hosted Cargo on a hub without `cargo_config`**, which is the hub as the rules_rust README + shows it: the hub's cargo does not see the patch registry that `.cargo/config.toml` defines + (`registry index was not found in any configuration`). Add + `cargo_config = "//:.cargo/config.toml"` to the `crate.from_cargo` call and commit that + file, or use vendored mode, or run `socket-patch rollback`. +- **Cargo on a hub with a cargo-bazel lock** (`lockfile`), in hosted and vendored mode: the + build stops at `The current lockfile is out of date` until the repin that message names + (`CARGO_BAZEL_REPIN=true bazel build ...`). After it the build is the patched one; in + hosted mode the hub needs `cargo_config` as well. +- **Hosted NuGet on a tag without `nuget_config`**: Bazel asks nuget.org alone and the + package fails the lock (`does not match its contentHash in packages.lock.json`). Give the + tag `nuget_config = "//:nuget.config"` and commit that file, which is the shape the table + lists; or run `socket-patch rollback`, which restores the lock and leaves the + `nuget.config` it created behind. +- **A hosted gem that `gem_checksums` pins**: the call still holds the gem to the upstream + sha256 (`Bundler found mismatched checksums`, or `Checksum was ... but wanted ...` on a + machine with an empty repository cache). Where the lock has no `CHECKSUMS` section the + build can also pass on the upstream gem from Bazel's repository cache. Run + `socket-patch rollback`. To keep the patch, delete the gem's line from `gem_checksums` + (Bundler still holds the gem to the `CHECKSUMS` section of the lock), or set it by hand to + the sha256 of the patched gem, which a later `rollback` does not put back. +- **npm on a hub with `update_pnpm_lock = True`.** Hosted mode with a pnpm of 11 or later, + when `pnpm-workspace.yaml` is not in the hub's `data`: the pnpm that Bazel runs rejects the + lock (`ERR_PNPM_TARBALL_URL_MISMATCH`). List `//:package.json` and + `//:pnpm-workspace.yaml` in `data`, as `docs/pnpm.md` of rules_js asks for. Vendored mode on + such a hub fails as well (measured with pnpm 9 and 10): the pnpm that Bazel runs does not + see `.socket/vendor`. Use hosted mode there. +- **Vendored Go with gazelle 0.36.0 or older**: `go_deps` rejects the directory `replace` + (`local file path not supported in replace directive`). Use hosted mode, or a gazelle of + the list above. +- **Vendored Cargo under rules_rust 0.75.0**, where the build passes: a build writes a + `BUILD.bazel` into the committed copy, and right after it `vendor --check` exits 1 + (`vendor_inventory_mismatch`) and `vex` writes no document. A second + `scan --mode vendored` puts the copy right. +- **`vex` for a hosted NuGet patch**, on a machine whose NuGet folder still holds the + unpatched package: it writes no document and exits 1 (`not_applied`), although the Bazel + build is the patched one. Where that folder holds nothing it attests the package. + ## Bazel workspaces: Maven A rules_jvm_external hub (`maven.install` in `MODULE.bazel`) builds the jars that its own lock, @@ -2249,7 +2388,9 @@ and gazelle walk like any other. A BUILD file in a copy (one the module ships, o `bazel run //:gazelle` writes there) is then a package of the workspace, gazelle's `go_deps` copies the directory with that file, and every target that uses the module fails to load (`No repository visible as '@rules_go'`). So socket-patch keeps the copies out of the -workspace's packages with `.bazelignore`. +workspace's packages with `.bazelignore`. Agent mode is +[not supported for Bazel builds](#bazel-workspaces-what-is-supported); its copies get the +line all the same, so that they cannot break the workspace. A project is in a Bazel workspace when its directory, or one above it up to the root of its git checkout, holds a regular file `MODULE.bazel`, `REPO.bazel`, `WORKSPACE` or `WORKSPACE.bazel` @@ -2974,8 +3115,8 @@ is patched: the file that points at the copy. rules_python 2.5.0-rc4 takes the path of the line for the name of a project, and the build of everything the hub serves fails (same three releases). A vendored npm tarball is built by rules_js and keeps its statement. So does a - vendored gem, for another reason: no build here has shown what rules_ruby does with one, - so nothing is said of it. + vendored gem, for another reason: no test here runs the build of one yet, so nothing is + said of it. Each advisory of such a patch gets a statement of the package's own with the status `affected`. It names that package alone under the product, and its `action_statement` says @@ -3069,7 +3210,7 @@ The document and the build are tested to agree on real Bazel 9.3.2, 8.8.2 and 7.7.2 for four shapes, all under Bzlmod: Go through gazelle's `go_deps.from_file(go_mod = "//:go.mod")` with `go_deps.config(check_direct_dependencies = "error")` and the module required directly in -`go.mod` (hosted, vendored and agent mode), npm through +`go.mod` (hosted and vendored mode), npm through aspect_rules_js's `npm.npm_translate_lock(pnpm_lock = "//:pnpm-lock.yaml")` (hosted and vendored), PyPI through rules_python's `pip.parse(requirements_lock = "//:requirements.txt")` (hosted), and RubyGems through rules_ruby's @@ -3102,8 +3243,9 @@ the build is broken): `-r`. Measured for PyPI, where the build fails. - **Vendored mode for RubyGems** beside `ruby.bundle_fetch`. rules_ruby 1.0.0-rc2 runs `bundle install` in a repository that holds the Gemfile, its lock and the files the call - lists as `srcs`, so the path of the copy may not exist there. Read from its source; no - build has been run, so the statement is left as it is. + lists as `srcs`, so the path of the copy does not exist there. Read from its source and + measured by hand, where the build fails; no test runs it yet, so the statement is left as + it is. - **A vendored package whose own files the hub does not read**, while the lock the hub does read still lists the registry's package: a uv or Poetry project vendored through `pyproject.toml` and its lock while `pip.parse` reads a requirements file exported before; diff --git a/docs/usage.md b/docs/usage.md index fd94cf856..98bc354e8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -318,6 +318,10 @@ scala-cli resolve into (restart a running sbt server, Bloop or Metals after [ecosystem caveats](ecosystems.md) before using agent mode in shared environments. The removed `setup` command is covered in the [migration guide](migrating-to-v5.md). +Agent mode is not supported for a package that Bazel builds: a Bazel build does not use +the installed copies. Use hosted or vendored mode there (see +[Bazel workspaces: what is supported](ecosystems.md#bazel-workspaces-what-is-supported)). + ## Inspect, undo, and repair | Command | Effect | From 3fa9af69a9dda646cb31f3813860f2bef4a3ad4a Mon Sep 17 00:00:00 2001 From: Mikola Lysenko Date: Fri, 20 Nov 2026 12:34:54 -0500 Subject: [PATCH 2/2] Say what "Not supported" means in the Bazel table, and what its VEX cells leave out A review of the new section found statements that were not true of every row, and gaps between it and the VEX section it links to: - "Not supported" and the agent mode paragraph said that the patch does not reach a Bazel build. That depends on the ruleset. They now say what the words mean here: no release promises what a Bazel build holds after the mode ran. The advice names hosted mode, and vendored mode only where the table lists it. - The table's words are the same as the v5 support tiers of the page, where "Not supported" means a refusal. A note says they are the table's own, and that several such cells run, exit 0 and break the build. - "Supported" promised a patched build with no other step. It now names the one exception, a build that may not update Bazel's own lock. - The VEX section named four tested shapes and told readers to publish nothing outside them, while the table called three more supported. The section now names the Cargo, Composer and NuGet flows that hold `vex` to their patched build, and no longer says that nothing else is checked. - The NuGet VEX cell now carries its condition: `vex` attests on a machine whose NuGet folder does not hold the package, and writes no document on the one that ran the scan. - The remedy for a gem that `gem_checksums` pins no longer says that Bundler holds the gem to the lock's CHECKSUMS section when the lock may have none. - The known problems gain the cases where a build passes on the unpatched package (a NuGet scan without a restore, a higher version of a Go module that another Bazel module requires, a `pip.parse` that reads another requirements file) and the access token that a hosted NuGet build prints in Bazel's output, which the NuGet flow records as a known gap. Co-Authored-By: Claude Fable 5.2 --- docs/ecosystems.md | 98 +++++++++++++++++++++++++++++++++------------- docs/usage.md | 7 ++-- 2 files changed, 74 insertions(+), 31 deletions(-) diff --git a/docs/ecosystems.md b/docs/ecosystems.md index 38851c031..4eec02f83 100644 --- a/docs/ecosystems.md +++ b/docs/ecosystems.md @@ -1786,34 +1786,43 @@ workspace and that Bazel does not build keeps the matrix at the top. | Go: gazelle `go_deps.from_file` over `go.mod` | Supported | Supported | Not supported | Supported with a hosted or vendored patch | | RubyGems: rules_ruby `ruby.bundle_fetch` over `Gemfile.lock` | Supported with no `gem_checksums` on the call | Not supported | Not supported | Supported | | Cargo: rules_rust `crate.from_cargo` over `Cargo.lock` | Supported with `cargo_config` on the hub | Supported | Not supported | Supported with a hosted or vendored patch | -| NuGet: rules_csharp `nuget.from_lock` over `packages.lock.json` | Supported with `nuget_config` on the tag | Not supported | Not supported | Supported with a hosted patch | +| NuGet: rules_csharp `nuget.from_lock` over `packages.lock.json` | Supported with `nuget_config` on the tag | Not supported | Not supported | Supported with no restored copy on the machine | | Composer: a rule of your own that runs `composer install` from `composer.lock` | Supported | Not supported | Not supported | Supported with a hosted patch | | Maven: rules_jvm_external `maven.install` with a `lock_file` | Supported with Bazel 7.4.0 or later | Not supported | Not supported | Supported with a hosted patch | -What a cell says: +These words are the table's own, not the [v5 support tiers](#v5-support-tiers). In +particular "Not supported" does not mean that the command refuses: in several cells it runs, +exits 0 and leaves a build that fails (the known problems below). What a cell says: - **Supported**, for hosted and vendored mode: after the one command of the mode (`scan --mode hosted` or `scan --mode vendored`; for Maven `get --mode hosted` at the Bazel root), the next `bazel build` takes the patched - package with nothing else to do, and the undo (`rollback`, `vendor --revert`) brings the - upstream build back. A test builds exactly that on a real Bazel, for the shape the list - below names. -- **Not supported**: do not use the mode for a package that Bazel builds. The patch does not - reach the build, or the build breaks (see the known problems below). + package with no other step, and the undo (`rollback`, `vendor --revert`) brings the + upstream build back. The one exception is a build that may not update Bazel's own lock + (see below). A test builds exactly that on a real Bazel, for the shape the list below + names. +- **Not supported**: socket-patch promises nothing about what a Bazel build holds after the + mode ran, so do not use it for a package that Bazel builds. In most of these cells the + patch does not reach the build, or the build breaks (see the known problems below). - **Supported**, for VEX: `socket-patch vex` and `--vex` say `not_affected` of a package the Bazel build takes patched, and `affected` of one whose patch Bazel does not build. [Bazel workspaces: VEX](#bazel-workspaces-vex) has the cases and the limits; a vendored gem is one of the limits. -- **Supported with a hosted (or vendored) patch**, for VEX: the document is right for a patch - that was applied in that mode. It is not checked against what Bazel builds, so of a package - whose patch is in no build of Bazel's (one that is only in an installed copy, say) it still - says `not_affected`. Do not publish that document. +- **Supported with a condition**, for VEX: under the condition the cell names, the document + says `not_affected` of a package the Bazel build takes patched, and a test holds it to + that (for Maven a test without Bazel). It does not say `affected` of a package whose patch + is in no build of Bazel's, one that is only in an installed copy, say: of that package it + still says `not_affected`. Do not publish that document. For Maven, + [Bazel workspaces: Maven](#bazel-workspaces-maven) says what `vex` checks of the hub before + it attests an entry. **Agent mode is not supported for Bazel builds, in any ecosystem.** Agent mode is made for the copies a package manager installed: `socket-patch apply` patches them after each install. -A Bazel build does not use those copies and runs no such step. Use hosted or vendored mode -for a package that Bazel builds. Agent mode stays what it is for whatever uses the installed -copies outside Bazel. +A Bazel build takes its packages from what its rulesets read and runs no such step. Whether +an agent-mode patch reaches a Bazel build differs from one ruleset to the next, and no +release promises it for any of them. Use hosted mode for a package that Bazel builds, or +vendored mode where the table lists it. Agent mode stays what it is for whatever uses the +installed copies outside Bazel. What the table was tested with: @@ -1831,7 +1840,9 @@ What the table was tested with: [`.bazelignore`](#bazel-workspaces-bazelignore). Hosted mode for Go has the limit of the matrix at the top: free-tier patches. - **RubyGems**: rules_ruby 1.0.0-rc2, `ruby.bundle_fetch` with `gemfile` and `gemfile_lock` - and no `gem_checksums`, and a `Gemfile.lock` that has a `CHECKSUMS` section. + and no `gem_checksums`, and a `Gemfile.lock` that has a `CHECKSUMS` section. That section + is what holds the patched gem to its sha256, in Bundler's step of the build: with a lock + that has none the build takes whatever the patch registry serves. - **Cargo**: rules_rust 0.75.0 (Bazel 9 and 8) and 0.56.0 (Bazel 7), `crate.from_cargo` with `cargo_lockfile = "//:Cargo.lock"`, `manifests = ["//:Cargo.toml"]` and `cargo_config = "//:.cargo/config.toml"`, and no cargo-bazel lock (`lockfile`). @@ -1858,8 +1869,7 @@ lock (`--lockfile_mode=error`) fails until one that may, or `bazel mod deps --lockfile_mode=update`, has rewritten it. Commit the rewritten lock with the patch. -Known problems. In each of these a command exits 0 today and the next Bazel build fails, -unless it says otherwise: +Known problems. In each of these a command exits 0 today and the next Bazel build fails: - **Vendored mode for PyPI, RubyGems, NuGet and Composer.** The path of the committed copy means nothing where Bazel runs: rules_python takes it for a package name, rules_ruby's @@ -1874,7 +1884,7 @@ unless it says otherwise: `cargo_config = "//:.cargo/config.toml"` to the `crate.from_cargo` call and commit that file, or use vendored mode, or run `socket-patch rollback`. - **Cargo on a hub with a cargo-bazel lock** (`lockfile`), in hosted and vendored mode: the - build stops at `The current lockfile is out of date` until the repin that message names + build stops at ``The current `lockfile` is out of date`` until the repin that message names (`CARGO_BAZEL_REPIN=true bazel build ...`). After it the build is the patched one; in hosted mode the hub needs `cargo_config` as well. - **Hosted NuGet on a tag without `nuget_config`**: Bazel asks nuget.org alone and the @@ -1886,9 +1896,10 @@ unless it says otherwise: sha256 (`Bundler found mismatched checksums`, or `Checksum was ... but wanted ...` on a machine with an empty repository cache). Where the lock has no `CHECKSUMS` section the build can also pass on the upstream gem from Bazel's repository cache. Run - `socket-patch rollback`. To keep the patch, delete the gem's line from `gem_checksums` - (Bundler still holds the gem to the `CHECKSUMS` section of the lock), or set it by hand to - the sha256 of the patched gem, which a later `rollback` does not put back. + `socket-patch rollback`. To keep the patch, set the gem's entry by hand to the sha256 of + the patched gem, which a later `rollback` does not put back. Where the lock has a + `CHECKSUMS` section, deleting the entry works too: Bundler then holds the gem to that + section. - **npm on a hub with `update_pnpm_lock = True`.** Hosted mode with a pnpm of 11 or later, when `pnpm-workspace.yaml` is not in the hub's `data`: the pnpm that Bazel runs rejects the lock (`ERR_PNPM_TARBALL_URL_MISMATCH`). List `//:package.json` and @@ -1898,13 +1909,35 @@ unless it says otherwise: - **Vendored Go with gazelle 0.36.0 or older**: `go_deps` rejects the directory `replace` (`local file path not supported in replace directive`). Use hosted mode, or a gazelle of the list above. -- **Vendored Cargo under rules_rust 0.75.0**, where the build passes: a build writes a - `BUILD.bazel` into the committed copy, and right after it `vendor --check` exits 1 - (`vendor_inventory_mismatch`) and `vex` writes no document. A second + +In these a command exits 0 and the Bazel build passes on the unpatched package: + +- **Hosted NuGet on a machine without a restore.** `scan` reads no package out of + `packages.lock.json`, so where only Bazel ever ran it finds none and writes nothing. Run it + where `dotnet restore` has run. +- **Go, when another Bazel module of the build requires a higher version** of the patched + module: gazelle builds that version and drops the replacement. With + `go_deps.config(check_direct_dependencies = "error")` and the module required directly in + `go.mod`, as in the list above, gazelle fails the build instead. +- **Hosted PyPI, when `pip.parse` takes the requirements of the build's platform from + another file** than the one socket-patch rewrote (`requirements_by_platform`, + `requirements_linux` and its siblings). + +[Bazel workspaces: VEX](#bazel-workspaces-vex) lists what the document says in such cases. + +And three that concern neither: + +- **Vendored Cargo under rules_rust 0.75.0**: a build writes a `BUILD.bazel` into the + committed copy, and right after it `vendor --check` exits 1 (`vendor_inventory_mismatch`) + and `vex` writes no document, although the build is the patched one. A second `scan --mode vendored` puts the copy right. - **`vex` for a hosted NuGet patch**, on a machine whose NuGet folder still holds the - unpatched package: it writes no document and exits 1 (`not_applied`), although the Bazel - build is the patched one. Where that folder holds nothing it attests the package. + unpatched package, as the one that ran the scan does: it writes no document and exits 1 + (`not_applied`), although the Bazel build is the patched one. Where that folder holds + nothing, as on a runner that only ran Bazel, it attests the package. +- **Hosted NuGet prints the access token of the patch in the build's output.** rules_csharp + asks the Socket source for every package of the lock, and Bazel prints a warning with that + source's URL, the token in it, for each package the source does not hold. ## Bazel workspaces: Maven @@ -3223,8 +3256,17 @@ after the undo `vex` writes no document. For PyPI on Bazel 8.5 and later a hoste `--lockfile_mode=error` fails until a build that may update the lock has run, and the updated lock has to be committed. -In every other Bazel shape nothing checks the document against the build, and in these the -document is still wrong (`not_affected` while Bazel builds the unpatched package, or while +Three more flows hold the document of `vex` to their patched build on the same releases, +after a hosted scan: Cargo through rules_rust's `crate.from_cargo` with `cargo_config` (and +after a vendored scan), Composer through a rule or a genrule of the project's own that runs +`composer install` from the lock, and NuGet through rules_csharp's `nuget.from_lock` with +`nuget_config`, on a machine whose NuGet folder does not hold the package. For these, and +for a Maven entry in `MODULE.bazel`, +[Bazel workspaces: what is supported](#bazel-workspaces-what-is-supported) says what the +document does not show. + +For no other Bazel shape do these pages say that the document and the build agree, and in +these the document is still wrong (`not_affected` while Bazel builds the unpatched package, or while the build is broken): - **Agent mode beside rules_js, rules_python or rules_ruby**, wherever the statement does diff --git a/docs/usage.md b/docs/usage.md index 98bc354e8..84aad7922 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -318,9 +318,10 @@ scala-cli resolve into (restart a running sbt server, Bloop or Metals after [ecosystem caveats](ecosystems.md) before using agent mode in shared environments. The removed `setup` command is covered in the [migration guide](migrating-to-v5.md). -Agent mode is not supported for a package that Bazel builds: a Bazel build does not use -the installed copies. Use hosted or vendored mode there (see -[Bazel workspaces: what is supported](ecosystems.md#bazel-workspaces-what-is-supported)). +Agent mode is not supported for a package that Bazel builds: Bazel takes its packages from +what its rulesets read, and runs no `socket-patch apply`. Use hosted mode there, or vendored +mode where [Bazel workspaces: what is supported](ecosystems.md#bazel-workspaces-what-is-supported) +lists it. ## Inspect, undo, and repair