Repository navigation
Decline PyPI and RubyGems vendored mode where a Bazel hub reads the lock - #2208
Mikola Lysenko (mikolalysenko) wants to merge 9 commits into
Conversation
Tests only. rules_python's `pip.parse` and rules_ruby's
`ruby.bundle_fetch` hand a lock of the checkout to Bazel. The real-Bazel
flows ran hosted mode beside both hubs, and vendored mode beside the
Python one (pypi::vendored_pip_parse, which holds `vex` to saying that
the build is not the patched one). No flow ran vendored mode for a gem,
and the PyPI flow did not build between its undo and its hosted scan.
ruby::vendored_bundle_fetch records what the command does today, in the
fixture of the hosted flow (rules_ruby 1.0.0-rc2; the call names the
`Gemfile` and the `Gemfile.lock` of the root). `scan --mode vendored
--yes` exits 0 with status `success` and one package applied. It commits
the unpacked gem with its specification and the ledger under
`.socket/vendor/gem/<uuid>`, gives the gem's declaration in `Gemfile` a
`path:`, and moves the gem's entry of `Gemfile.lock` into a `PATH`
section. The next `bazel build` fails in the `bundle install` action of
the hub. rules_ruby copies the two files into a repository of Bazel's
and runs Bundler there, which stops with
The path
`<execroot>/external/<hub>/.socket/vendor/gem/<uuid>/sp-victim-1.0.0`
does not exist.
`vex` attests the gem as patched meanwhile: it reads the committed copy,
and what rules_ruby builds from one is not judged. `vendor --revert`
puts every file back, and the build with them.
pypi::vendored_pip_parse now names the failure it asserts. rules_python
makes the name of a repository from the path of the vendored line, and
Bazel stops with `invalid user-provided repo name
'pip_311__/_socket/vendor/pypi/<uuid>/spvictim_1_0_0_py2_py3_none_any_whl'`.
The flow also builds right after `vendor --revert`: the unpatched build
is back before hosted mode pins the patch.
Both flows pass on Bazel 9.3.2 with the product code as it is. Each
compares the tool's message without white space: Bundler breaks its
message at the width of the console it runs in, which differs from one
machine to the next.
The two Ruby flows share their stand-in. `Served::to` builds the gems of
a run, serves them, grants the patch and routes Bazel's downloads, as
the hosted flow did inline. The grant now holds what the patch service
grants for a gem: the patched gem with a sha512, and its specification.
Vendored mode downloads both, and hosted mode neither. The record of the
patch holds the hashes of the gem's one file, in place of the
placeholders of the shared stand-in.
bazel-ruby.yml says in its header that the legs run both modes, and a
pull request that changes vendor/gem.rs now starts them: the file was
in the list of the pushes to main alone.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
rules_python's `pip.parse` and rules_ruby's `ruby.bundle_fetch` build
the packages of a lock in repositories of Bazel's own. Vendored mode
makes that lock name the patched copy by a path under `.socket/vendor`,
and neither ruleset builds from such a lock. The command exited 0 with
status `success`, and the next `bazel build` failed for everything the
hub serves (Bazel 9.3.2, 8.8.2 and 7.7.2, the flows of the previous
commit):
- PyPI: rules_python 2.5.0-rc4 makes the name of a repository from the
path of the vendored line, `invalid user-provided repo name
'pip_311__/_socket/vendor/pypi/<uuid>/<wheel>'`.
- RubyGems: rules_ruby 1.0.0-rc2 runs `bundle install` in a repository
that holds the Gemfile and its lock and not the copy, `The path
.../.socket/vendor/gem/<uuid>/<name>-<version> does not exist.`
Vendored mode now declines such a package before it downloads or writes
anything, with `vendor_pypi_bazel_hub` or `vendor_gem_bazel_hub`. The
refusal rests on what the files of the workspace say and on what the
run would write, so it is for a run that would write a file a hub
reads, and for no other.
When it declines. The project is in a Bazel workspace
(`bazel::bazel_root`), and a call of its files names, by a label
written out as a string, a file of the project that the run for the
package would point at a copy:
- a `pip.parse` whose `requirements_lock`, `requirements_by_platform`,
`requirements_darwin`, `requirements_linux`, `requirements_windows`
or `uv_lock` names a requirements file of the project that the run
would write (`requirements.txt` or a file it includes with `-r`), or
the `uv.lock` of a uv project;
- a `ruby.bundle_fetch` whose `gemfile` or `gemfile_lock` names the
project's `Gemfile` or `Gemfile.lock`;
- a call of a `WORKSPACE` file that passes one of those attributes,
which is how the older form of either ruleset is called there
(`pip_parse`, `rb_bundle_fetch`).
Which files a PyPI run writes is asked of the backend's own router
(`vendor::pypi::hub_files`). A project with no tool lock is wired
through its requirements files, so they count. A uv, Pipenv or PEP 751
lock is wired together with a pin of the package in the requirements
files beside it, so they count for a package they name (a pin, a
hosted pin that a takeover restores first, or the vendored line of an
earlier patch) and not for one they do not name. A Poetry or PDM lock
is wired alone: such a project is not declined beside a hub that reads
the requirements file exported from its lock, and is vendored as it is
without Bazel.
Every such call counts, also one that may not run (in a comprehension).
Every package whose run would write a file the call names is declined,
since the lock is the project's, but one that is already vendored
(below).
What an uncertain reading does. Where the files of the workspace
cannot be read with certainty and a call of the hub may be behind
that, every package whose run would write such a file is declined, in
every project of the workspace:
- a call of the hub whose file is not a plain string, or that passes
`*` or `**`, and a hub proxy handed to anything but `use_repo` or
`inject_repo`;
- a module file that is missing or cannot be read, or a statement of
one that cannot be read, where the workspace calls the hub or a file
that was read names its ruleset (a `bazel_dep` on it, or a
`use_extension` of the hub's `.bzl` file under any repository name);
- a root `MODULE.bazel` or a `WORKSPACE` file that cannot be read at
all.
The last two matter because Bazel builds files that are not read here:
one byte that is not UTF-8 is enough, in a comment too, and so is a
file over 1 MiB. Without them the call in such a file was not seen and
the run went on. Going on there can leave a broken build behind a
command that exited 0, and declining costs a vendored run that the
switch brings back. A workspace whose root `MODULE.bazel` and
`WORKSPACE` file were read or are not there, and in which no file that
was read calls the hub or names its ruleset, is never declined for it,
whatever else cannot be read.
Where nothing changes. Outside a Bazel workspace, in a workspace that
calls neither hub, and for a package whose run writes no file that a
call names (a project beside the one a hub reads, one whose
`requirements.txt` is not the file the hub is given, a Poetry or PDM
project whose exported requirements the hub reads), vendored mode
prints what it printed and writes what it wrote. Other ecosystems,
hosted mode and agent mode are not touched.
Where it is asked. `bazel::built` already says for `vex` which hub
reads which lock; `reader` there answers this question from the same
table and the same reader of workspace files, and takes `uv_lock` as
one more attribute. `vendor::bazel_hub::refusals` asks it about the
files the run of each package would write and words the refusal.
`vendor::refusals::bazel_workspace_refusals`, the one answer every
vendored entry point takes for a refusal that rests on the Bazel
workspace, returns it beside the Composer refusal. So it reaches
`scan --mode vendored`, `get --mode vendored`, `vendor` for a patch the
manifest records, the takeover of a hosted pin by a vendored scan, and
the eject of one by `vendor`, which asks once and before it fetches a
record. No command's own code changes.
The package is a `failed` event and the run exits 1 (`partialFailure`;
for the eject `eject_refused`, detail `kept hosted: ...`). A dry run of
`scan` or `get` lists the package as one the run would refuse and exits
0; `vendor --dry-run` reports the refusal and exits 1, as it does for
any package it could not vendor. Nothing is written, no patch is
downloaded, and a hosted pin stays. These are the exit codes of the
Composer refusal. The detail names the call with its file and line, the
lock, the Bazel root and hosted mode:
`pip.parse` (MODULE.bazel:15) of the Bazel workspace at /repo names
requirements.txt; vendored mode makes the lock name the patched
copy by a path under .socket/vendor, and rules_python fails the
build on such a lock; use `--mode hosted`, which names the patched
package by a URL that rules_python fetches, or pass
`--allow-vendored-in-bazel` if no build takes the packages of this
project from rules_python
For a doubt it names the file, the line and the reason in the place of
the call. Hosted mode pins the patch in the same file, and both
rulesets build it: the two flows end with that build. For a gem the
detail adds the condition under which rules_ruby builds a hosted pin,
"where its call passes no `gem_checksums`": with an entry for the gem
there the hosted build fails, which the docs list as a known problem.
`--allow-vendored-in-bazel` (SOCKET_ALLOW_VENDORED_IN_BAZEL) lifts the
refusal, as it lifts the Composer one: for a hub that no build uses, a
`WORKSPACE` file that the Bazel in use does not read, or a
`ruby.bundle_fetch` that is given the files of the copy as `srcs`. Its
help text, its row in CLI_CONTRACT.md and the sentence of
docs/ecosystems.md that named Composer as the one refusal it lifts now
name the three.
`vendor --revert` is not refused. Neither is a package that is already
vendored, as for Composer. What is declined is the write of the path
into the lock the hub reads, so a package that the file the call names
already names by the copy of the same patch
(`.socket/vendor/pypi/<uuid>/`, `.socket/vendor/gem/<uuid>/`, outside a
comment) is let through: the run adds nothing to what the hub reads. A
project vendored with the switch, or by an earlier release, keeps
passing its in-sync runs without the switch, a `scan` or `get` that
names no mode included, which runs in vendored mode there. A new patch
for that package, and any other package, is declined as before. It is
the named file that decides, not any file of the project: a uv project
whose lock names the copy while the hub reads a requirements file that
still pins the registry's release would have that file rewritten by
the run, and is declined. That file is read as a lock of the workspace
is (`built::lock_text`): up to 64 MiB, and not through a link that
leads out of the Bazel root, so such a link lets nothing through.
Where the reading is in doubt no file is known to be the hub's, so
nothing is let through there. Such a run passing does not make the
build the patched one: for PyPI `vex` says `affected` of that state.
No line a person reads is new: the refusal prints where every refused
vendored package does.
Tests:
- pypi::vendored_pip_parse and ruby::vendored_bundle_fetch (real
Bazel) now hold the command to the refusal: exit 1, the code, a
detail that names the call, the lock, `--mode hosted` and the switch,
no file changed and no request for the patched wheel or gem. The same
build passes on the upstream package. With the switch the
expectations of the previous commit are back: the package is
vendored, the build fails with the ruleset's message, and
`vendor --revert` restores the build. Hosted mode then builds the
patched package.
- Hermetic tests of both files, on steps the harness now holds for
both: every command that would vendor declines and writes nothing,
the dry runs and the eject among them; vendored mode goes on with
the switch and with its variable, a later run without them passes
and writes nothing, a scan that names no mode included, and
`vendor --revert` needs neither; it goes on with no switch in a
workspace whose hub reads another file, in a project beside the one
it reads, and in no workspace; a hub whose file is not written out
declines. For PyPI also: a Poetry project beside a hub that reads its
exported `requirements.txt` is vendored with no switch, that file
stays as it is and the later runs pass; and a `MODULE.bazel` with one
byte that is not UTF-8 declines.
- Unit tests of `built::reads` (each attribute, a call that may not
run, `uv_lock`, another project, another repository, a doubt of the
call, of the proxy and of the workspace, a hub that is not called,
the `WORKSPACE` file; a root module file, an included file and a
`WORKSPACE` file that cannot be read, with a root that names the
ruleset as a dependency, by its extension, or not at all), of the
refusal (codes, words, the switch, a file brought in with `-r`, the
`Gemfile` alone, no workspace; a package the named lock already
names by the patch's copy, and the same copy named in a comment, in
another file, behind a link out of the root or under a doubt; a
Poetry and a PDM lock, and a uv and a Pipenv lock beside a
requirements file that names the package or does not) and of its
dispatch.
Four tests of pypi.rs vendored a wheel beside the hub that reads the
requirements, to hold `vex` to what it says of that state. The command
that writes the line now has the switch there, and they assert what
they asserted; the in-sync runs after it have none, as before.
Docs: docs/ecosystems.md "Bazel workspaces: PyPI and RubyGems vendored
mode", the two rows of the matrix, and what "Bazel workspaces: VEX"
says of a vendored gem, which a build has now shown; the rows of the
two codes, of the switch and of the vendored table in CLI_CONTRACT.md.
In "Bazel workspaces: what is supported" the two vendored cells stay
"Not supported", and the note on that word now says that the command
declines there. The entry of the known problems for vendored mode
listed commands that exit 0 and leave a failing build: PyPI and
RubyGems leave it, and so does Composer, which declines since the
change before this one; NuGet stays. bazel-pypi.yml and bazel-ruby.yml
start their legs for a change to vendor/bazel_hub.rs and
vendor/refusals.rs, and bazel-pypi.yml for one to vendor/pypi.rs. The
`bazel` group of scripts/loc-budget.json follows the 69 lines added to
built.rs.
Not covered: a hub call in a `.bzl` file that a `WORKSPACE` file
loads, a hub of another Bazel module, another tag or ruleset that reads
the same file under Bzlmod, a `WORKSPACE` call that hides its arguments
behind `**`, a Bazel root above the git checkout, and a hub whose call
and whose `bazel_dep` are both in an included file that cannot be read
while the files that were read name neither: vendored mode goes on
there as before. A package of a uv, Pipenv or PEP 751 project that the
hub's requirements file names in a form that is not wired with the
lock (a range, extras) is declined although the run would leave that
file alone. `vex` still attests a gem that was vendored with the switch
as patched, while its build fails.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…reads A review of the PyPI and RubyGems vendored declines found three states in which the run was let through and would write a file that a hub of the Bazel workspace reads: - A Poetry or PDM project whose exported requirements file holds the package by a URL, which is what a hosted pin is. The lock of such a project is wired alone, so its requirements files did not count, but a vendored run that takes a hosted pin over restores that line. The files now count for a package they hold by a URL. A package they pin from the registry is vendored as before. - A `WORKSPACE` call that names the lock through the name the file gives the main repository (`@shop//api:requirements.txt` beside `workspace(name = "shop")`). The label was taken for another repository's. It is the main repository now, for the calls of that file. - A package that is already vendored, where the calls name more than one file of the project. Only the first file a call names was read, so a `uv.lock` locked again beside a vendored requirements file let the package pass, and the run rewrote the lock. Each file a call names that holds the package now has to name the copy; one that cannot be read may hold it. Also from the review: the requirements file is no longer listed twice, the gem's two files are the gem backend's own constants, and the files of a package are chosen by its ecosystem and not by the text of its purl type. The docs and the contract row say what was imprecise: the requirements files of a project with no tool lock count as one set, also for a package a file of the set does not pin, because a file the hub reads can bring in the rewritten one with `-r`; and the `pip_install(requirements = ...)` of an older rules_python is not seen. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview A new
Reviewed by Cursor Bugbot for commit 2d652c5. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2d652c5. Configure here.
Two states in which a vendored PyPI run was still let through and would write a file a Bazel hub reads: - A hub that names a requirements file which brings the project's own in with `-r` (`all.txt` with `-r requirements.txt`). The files a run writes are walked down from `requirements.txt`, so the file the hub named was not among them and nothing was declined. A requirements file a call names now counts as naming each file its `-r` includes reach, read inside the Bazel root as any lock is, and the refusal names it. - An already-vendored package whose other files a call may name where the reading is in doubt: a second attribute that is not written out, or a call that may be behind a file that could not be read. Only a certain answer had that file read; a doubt was dropped and the package let through. A doubt now has the file read as well, so the package is declined where that file holds it and not by the copy. The `bazel` line budget goes from 2574 to 2611. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQFeU3sKRPzawaNLsm Assisted-by: Claude Code:claude-opus-5-5
|
[agent] PR shepherd: this PR needs a person for two things.
Both Bugbot threads are fixed, each with a unit test that fails without the fix, and resolved. I'll post the review brief once CI is green on 9a022a8 and this label is removed. Generated by Claude Code |
|
The description is back: the version from before the mistaken edit, with a tenth decision for the parent-file case of 9a022a8, a line on that commit under "Code review", and the current status. The label stays until the maintainer has answered decision 10. |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Found an unnecessary refusal on Bazel 9 workspaces.
| let tag = format!("{}.{}", hub.extension.name, hub.tag); | ||
| let tagged = tags.calls.iter().map(|at| (at.file, at.call, tag.as_str())); | ||
| // In a `WORKSPACE` file, the calls that pass one of the hub's files. | ||
| let legacy = workspace |
There was a problem hiding this comment.
[agent] Please exclude legacy WORKSPACE files when the checkout pins Bazel 9 or later. A retained WORKSPACE from a migration can still mention Gemfile.lock or requirements.txt, but Bazel 9 never loads it. Counting it here makes a previously working vendored run exit 1 in a workspace with no active hub consuming the lock. The Maven reader already gates its legacy check on the declared Bazel release, which would preserve the Bazel 7 protection here.
…hub-locks Three files conflicted. The RubyGems tests of e2e_bazel_build keep one `Served` (this branch's `Served::to`, with main's `neighbour_gem`), one `run` and every test of both sides; main's tests beside a `gem_checksums` use them, and its `checkout` is `checkout_with`, which this branch's `checkout` is built on. docs/ecosystems.md keeps the entries of both sides, and its paragraph on hosted mode beside a `gem_checksums` entry now says what hosted mode does there since main. The `bazel` cap of scripts/loc-budget.json is the count of the merged tree, 3740. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hub-locks No file conflicted. Main's change to hosted pnpm pins adds to bazel/pnpm.rs, so the `bazel` cap of scripts/loc-budget.json is the count of the merged tree again, 3858. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gnore line `cargo::vendored_from_cargo_with_config` comments out the line the scan wrote in `.bazelignore` and expects `bazel cquery //...` and `bazel query 'deps(//...)'` to fail on a repository that the main repository does not see. It looked for the hub's repository (`@crates__...`) alone. The build file that cargo-bazel writes into the committed copy names `@platforms` as well, and Bazel reports the first one it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms` and the flow failed on its own check. The flow now takes either name for that failure. Test only: nothing the command does changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out now reads the name out of Bazel's message and takes it only when the message is about the main repository's view: `platforms`, or a repository of the crate hub. The same words about another repository's view, or about another name, are a different failure and no longer pass for the expected one. A test without Bazel holds the check to the two messages that were seen and to three it must not take. The module docs, the comment at the call and the section on the build file in a vendored crate said the commands end on the dependency's repository alone. They now name `platforms` as well, which is what a user who comments the line out can see. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hub-locks Two files conflicted. vendor/refusals.rs keeps every refusal of both sides in the one dispatch of `bazel_workspace_refusals`, which is still asked once and before any fetch: Composer's, then this branch's for a PyPI or RubyGems project whose lock a hub reads, then main's for a Maven jar that only a rules_jvm_external hub builds. Its docs say which of them the user's word lifts. The `bazel` cap of scripts/loc-budget.json is the count of the merged tree, 4042. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Decided by the maintainer on 2026-11-25 (decision 10 of the description): keep the refusal where a hub names a parent requirements file that brings the project's own in with |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Re-reviewed the commits since the last approval; no major findings.

Vendored mode now declines a PyPI or RubyGems package when a rules_python or rules_ruby hub of the project's Bazel workspace reads the lock it would rewrite (
vendor_pypi_bazel_hub,vendor_gem_bazel_hub), where it used to exit 0 and leave a build that fails.It follows #2186, which declines Composer vendored mode in a Bazel workspace. It uses that change's switch (
--allow-vendored-in-bazel), its exit codes, and its one entry for refusals that rest on the Bazel workspace.Based on main, in two commits. The first is tests only and records what main does today. The second is the change, with the expectations of the first changed to match.
Decisions for the maintainer
MODULE.bazelorWORKSPACEfile that cannot be read, in a workspace that may not use the ruleset at all. The other choice is to go on as today, which keeps a vendored run for such a workspace and breaks the build for one whose hub does read the lock.WORKSPACEcall counts, although Bazel 8 and 9 may not read that file. Without it,pip_parseandrb_bundle_fetchworkspaces on Bazel 7 keep the broken build.vendor_pypi_bazel_hubandvendor_gem_bazel_hub.vexfor a gem vendored with the switch. rules_ruby builds a vendored gem only when the call lists the copy's files assrcs, which is not read. Shouldvexsayaffectedthere, as it does for PyPI?-r(pip.parse(requirements_lock = "//:all.txt"), whereall.txthas-r requirements.txt). A later commit on this branch (9a022a8) counts such a file as naming every file its-rincludes reach, so the run is declined, and it is declined also when the project is already vendored and in step, because the parent file never names the vendored copy itself. The switch lifts it. The other choice is to let the already vendored case through after checking the included files for the copy.What the code does today
rules_python's
pip.parseand rules_ruby'sruby.bundle_fetchhand a lock of the checkout to Bazel, which builds the packages the lock names in repositories of its own. Vendored mode makes that lock name the patched copy by a path under.socket/vendor. Neither ruleset builds from such a lock.scan --mode vendored --yesbazel buildsuccess, 1 applied. The package's line ofrequirements.txtbecomes./.socket/vendor/pypi/<uuid>/<wheel> --hash=...invalid user-provided repo name 'pip_311__/_socket/vendor/pypi/<uuid>/<wheel>'success, 1 applied.Gemfilegets apath:,Gemfile.lockaPATHsectionbundle installaction:The path .../.socket/vendor/gem/<uuid>/<name>-<version> does not exist.Both on Bazel 9.3.2, 8.8.2 and 7.7.2.
vendor --revertputs the files and the build back. The first commit records this in two real-Bazel flows that pass on the code as it is; the second commit changes what they expect.What changes
A package is declined when both of these hold:
MODULE.bazel,REPO.bazel,WORKSPACEorWORKSPACE.bazel.pip.parserequirements_lock,requirements_by_platform,requirements_darwin,requirements_linux,requirements_windows,uv_lockrequirements.txtand each file it includes with-r, where the run would write them;uv.lockin a uv projectruby.bundle_fetchgemfile_lock,gemfileGemfile,Gemfile.lockWORKSPACEfile that passes one of those attributes (pip_parse,rb_bundle_fetch)Which files a PyPI run writes is asked of the vendored backend's own router, so the refusal follows what the run does:
Every such call counts, also one that may not run (in a comprehension). The refusal is for every package whose run would write a file the call names, except a package that is already vendored (below).
An uncertain reading declines too. Where the files of the workspace cannot be read with certainty and a call of the hub may be behind that, every package whose run would write such a file is declined, in every project of the workspace:
*or**;use_repoorinject_repo;bazel_depon it, or ause_extensionof the hub's.bzlfile);MODULE.bazelor aWORKSPACEfile that cannot be read at all.A file cannot be read here when one byte of it is not UTF-8 (a name in a comment is enough) or when it is over 1 MiB, and Bazel builds both. Going on there can leave a broken build behind a command that exited 0. Declining costs a vendored run, which the switch brings back. A workspace whose root
MODULE.bazelandWORKSPACEfile were read (or are not there), and in which no file that was read calls the hub or names its ruleset, is never declined for it.A package that is already vendored passes. What is declined is the write of the path into the lock the hub reads. So a package is let through when the file that the call names already names the copy of the same patch (
.socket/vendor/pypi/<uuid>/,.socket/vendor/gem/<uuid>/, outside a comment): the run adds nothing to what the hub reads. A project that was vendored with the switch, or by an earlier release, keeps passing its runs without the switch, ascanorgetwith no--modeincluded, which runs in vendored mode there. A new patch for that package, and any other package, is declined. This is the rule #2186 has for Composer, with three differences that come from the hub:uv.locknames the copy, while the hub reads a requirements file that still pins the registry's release, would have that file rewritten by the run. It is declined.Where nothing changes. Outside a Bazel workspace; in a workspace that calls neither hub; for a package whose run writes no file that a call names (a project beside the one a hub reads, one whose
requirements.txtis not the file the hub is given, a Poetry or PDM project whose exported requirements file the hub reads); for other ecosystems and other modes. There the command prints what it printed and writes what it wrote.What a user sees.
scan --mode vendored,get --mode vendoredandvendor(for a recorded patch, for the takeover of a hosted pin, and for the eject of one) report the packagefailedwith the code and exit 1 (partialFailure;eject_refusedwithkept hosted: ...for the eject).scanandgetwith--dry-runlist the package as one the run would refuse and exit 0;vendor --dry-runexits 1, as it does for any package it could not vendor. Nothing is downloaded, nothing is written, a hosted pin stays. No line a person reads is new. The message:For an uncertain reading it starts with the place and the reason instead:
Hosted mode pins the patch in the same file and both rulesets build it; the two flows end with that build. For a gem the message names the condition of that: after "a URL that rules_ruby fetches" it says "where its call passes no
gem_checksums". With agem_checksumsentry for the gem the hosted build fails, which the docs list as a known problem.--allow-vendored-in-bazel(SOCKET_ALLOW_VENDORED_IN_BAZEL=1) lifts the refusal, and the run then does what it did before.vendor --revertis never refused.Where the code is. The refusal goes through
vendor::refusals::bazel_workspace_refusals, the one answer every vendored entry point already takes. No command's own code changes:commands/vendor.rshas no diff, and the eject still asks once, before it fetches a record.Limits
.bzlfile that aWORKSPACEfile loads, a hub that another Bazel module declares, another tag or ruleset that reads the same file under Bzlmod (rules_ruby's olderruby.bundle, rules_pycross, aspect_rules_py), aWORKSPACEcall that hides its arguments behind**, a Bazel root above the git checkout, and a hub whose call and whosebazel_depare both in an included file that cannot be read while the files that were read name neither.WORKSPACEfile that names the lock while the Bazel in use does not read that file (Bazel 9 never does, Bazel 8 only with--enable_workspace), a hub call that never runs, and a workspace that does not use the ruleset while its rootMODULE.bazelor itsWORKSPACEfile cannot be read here, or while a file that was read names the ruleset and another cannot be read.-r; theGemfilewhen the lock does not name the copy), every already vendored package where the reading is uncertain, and a package of a uv, Pipenv or PEP 751 project that the hub's requirements file names in a form that is not wired with the lock (a range, extras). The switch, or its variable in the environment of those runs, lifts it.vexdoes not say so yet; the docs list that among the limits of VEX.vexsaysaffectedof that state and names the way out:vendor --revert, thenscan --mode hosted.vexstill attests a gem that was vendored with the switch as patched, while its build fails. The flow records that.uv.lockrests on the rule, not on a build.Contents and sizes
crates/socket-patch-core/src/bazel/built.rs:reader, which answers "does a call of this ecosystem's hub name one of these files, or is that in doubt" from the table and the reader of workspace files thatvexalready uses.uv_lockis one more attribute there; thevexjudgement does not change.lock_text, whichvexreads a lock with, is now also what reads the hub's lock. +161/-24 lines, 88 of them code.crates/socket-patch-core/src/vendor/bazel_hub.rs(new): asks the reader about the files the run of each package would write, words the refusal, and lets an already vendored package through. 221 lines, 144 of them code.vendor/pypi.rs(+45, 26 code) andvendor/pypi_requirements.rs(+30, 18 code):hub_files, which says through the backend's router which of those files a run for a package would write.vendor/refusals.rs:bazel_workspace_refusalsreturns this refusal beside the Composer one. +15/-7 lines, 4 of them code.args.rs), its row inCLI_CONTRACT.mdand the sentence indocs/ecosystems.mdthat named Composer as the one refusal it lifts now name the three.scripts/loc-budget.py(223 before the code review). Thebazelgroup's budget goes from 2486 to 2574, the count of this tree.src; +841/-158 lines intests/e2e_bazel_build(harness.rs+134,pypi.rs+268/-79,ruby.rs+439/-79). No fixture file and no binary file is added.docs/ecosystems.md: the new section "Bazel workspaces: PyPI and RubyGems vendored mode", the two matrix rows, and the VEX section's sentences about a vendored gem. In "Bazel workspaces: what is supported" the two vendored cells stay "Not supported"; the note on that word now says that the command declines for PyPI, RubyGems and Composer; and the known-problems entry for vendored mode, which lists commands that exit 0 and leave a failing build, is now NuGet alone.CLI_CONTRACT.md: a row for the two codes, the switch's row, three rows of the vendored table.bazel-ruby.ymlsays that its legs run both modes; both workflows start their legs for a change tovendor/bazel_hub.rsandvendor/refusals.rs,bazel-pypi.ymlforvendor/pypi.rs, andbazel-ruby.ymlforvendor/gem.rs.What it proves, and where
bazel-pypi.ymlandbazel-ruby.ymlrun on this pull request).pypi::vendored_pip_parseandruby::vendored_bundle_fetch: the scan declines (exit 1, the code, the message, no file changed, no request for the patched wheel or gem); the same build passes on the upstream package; with the switch the package is vendored and the build fails with the ruleset's message;vendor --revertrestores the build;scan --mode hostedthen builds the patched package.pypi::hosted_pip_parseandruby::hosted_bundle_fetchpass on the same three releases. Both failure messages are compared without white space, since Bundler breaks its message at the width of its console..git), a project beside the one the hubs read, and the root of a workspace whose hubs name other files; PyPI and RubyGems; scan, rescan, dry run,get,vendor, eject, takeover, revert, as JSON and as a person reads them. Exit codes, both streams and every file are equal byte for byte (only timestamps are normalised). In the control, where the hubs read the project's files, all 20 sequences differ.get,vendor, dry run,vendor --check, revert; PyPI and RubyGems) are equal byte for byte. A Poetry project that main's binary vendored beside a hub that reads its exportedrequirements.txtpasses its later runs with this head, with the exit codes and events of main's.pypi.rsandruby.rs: every command that would vendor declines and writes nothing, the dry runs and the eject among them; the switch and its variable; a later run without them passes and writes nothing;vendor --revertneeds no switch; no refusal where the hub reads another file, beside the project it reads, with no workspace file, or for a Poetry project whose exported requirements the hub reads; a hub file that is not written out declines, and so does aMODULE.bazelwith a byte that is not UTF-8.uv_lock, another project, another repository, each kind of doubt, a hub that is not called, theWORKSPACEfile; a root module file, an included file and aWORKSPACEfile that cannot be read), of the refusal (codes, words, the switch, theGemfilealone; a package the named lock already names by the patch's copy, and the same copy named in a comment, in another file, behind a link out of the root, or under a doubt; Poetry, PDM, uv and Pipenv locks beside a requirements file that names the package or does not) and of its dispatch.Gemfilealone, the gem's hosted condition) were tried one at a time; each fails a test.pypi.rsvendored a wheel beside the hub that reads the requirements, to holdvexto what it says of that state; the command that writes the line now has the switch there, and they assert what they asserted.Not covered
pip.parsewith a hashedrequirements.txt;ruby.bundle_fetchwithoutgem_checksums), with one release of each ruleset. TheWORKSPACEforms,uv_lock, a file brought in with-r, the uncertain reading, a file that cannot be read, a Poetry project and the already vendored pass are covered by unit and hermetic tests, not by a build.uv.lock, and no build after a vendored run under a module file with a byte that is not UTF-8 (Bazel 9.3.2 was only seen to accept such a file).requirements.txtandGemfileprojects. uv, Pipenv and PDM projects were not run with a binary; what counts for them rests on unit tests of the rule over the backend's router.getwith no--modein an already vendored project is not tested on its own (the scan with no mode is).Code review
Nine findings on the two commits. Each was checked against the code; three were also held to a failing unit test before the fix. The fixes are one further commit, "Close three ways a vendored run could still write a file a Bazel hub reads".
Fixed:
WORKSPACEcall that names the lock as@<name>//..., where the file saysworkspace(name = "<name>"), was taken for another repository's file: no refusal and no doubt. It is the main repository now for the calls of that file.uv.locklocked again beside a vendored requirements file passed, and the run rewrote the lock. Each file a call names that holds the package now has to name the copy; one that cannot be read may hold it.requirements.txtwas listed twice in the files of a project with no tool lock.Not fixed, and why:
base.txt, the package is pinned indev.txt). Narrowing this to the files that pin the package would miss a hub-read file that brings in the rewritten one with-r, and that is a failed build after exit 0. The decline is kept; the module docs, the docs table and the contract row now say that the files count as one set, and the case is in the limits.pip_install(requirements = ...)of an older rules_python in aWORKSPACEfile is not seen. No build was run on it, and the attribute name is one that other rules use for other things (a test holds that anhttp_archivewith it is not taken for a hub). It is in the docs' list of what is not seen.After the fixes, on macOS:
cargo checkon all targets, clippy with-D warningson the workspace and on thee2e_bazel_buildtarget,rustfmt --checkon the changed files, the whole core unit suite (8378),e2e_bazel_buildwithout Bazel (55),cli,cli_global_argsandspawn_env_hygiene(152), the vendored PyPI and gem integration targets (716), the script tests, the line budget and actionlint: all pass. On real Bazel 9.3.2 the two PyPI flows and the two RubyGems flows pass. Three mutations, one per behaviour fix, each fail a unit test. Bazel 8.8.2 and 7.7.2 were not rerun after the fixes; the CI legs run them.A later commit, 9a022a8, closes two more states a review bot found, each with a unit test that fails without the fix: a hub that names a requirements file which includes the project's own with
-r(decision 10 above), and an already vendored package whose other file a call may name where the reading is in doubt. It takes thebazelline budget from 2574 to 2611.🤖 Generated with Claude Code