Repository navigation
Accept the BUILD.bazel that cargo-bazel writes into a vendored crate - #2190
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Vendored mode keeps a patched crate under `.socket/vendor/cargo` and points a `[patch.crates-io]` path entry at it. Under a rules_rust crate hub (`crate.from_cargo`) the next build is the patched one, and from rules_rust 0.59.0 on the hub's tool, cargo-bazel, also writes a `BUILD.bazel` into that copy: it renders the build file of a crate the workspace takes from a path to `<path>/BUILD.bazel`, each time Bazel evaluates the hub (`crate_universe/src/rendering.rs`, `render_build_files`). The real-Bazel flow of vendored mode already pinned, as known gaps, that `vendor --check` and `vex` then take the copy for a changed one. This adds what was not yet measured about that file and records what the code does with it today. No product code changes. The crate of the fixture gets a dependency: a second crate, which the stand-in registry serves and the fixture's `Cargo.lock` lists, with a placeholder for its checksum as for the crate itself. Without a dependency the build file that cargo-bazel renders names no repository of the hub, and Bazel analyses it without trouble. The hosted flow builds the same crate and passes as before; the index of its patch registry names the dependency as crates.io's. On real Bazel (`cargo::vendored_from_cargo_with_config`; run on 9.3.2 with rules_rust 0.75.0): - The file starts with the banner of every file cargo-bazel renders. - It makes the copy a package of the user's workspace: `bazel query //...` lists two targets there, and `bazel build //...` passes. The package names the repository of the dependency, which only the hub sees, so `bazel cquery //...` and `bazel query 'deps(//...)'` fail on it (`No repository visible as '@crates__...'`): a third known gap of the flow. With a `.bazelignore` line for `.socket/vendor/cargo`, which the test writes as a user would, `//...` is the user's own target again, both commands pass, and the build is still the patched one: the hub reads the copy by its path, copies it into a repository of its own and renders the build file of that repository again. - So a build file that someone else puts into the copy does not reach the crate: with one under the same banner the build still prints the patched marker. It is a package of the workspace all the same, and `bazel build //...` builds its target. `vendor --check` reports it (`vendor_inventory_mismatch`), as it reports the file cargo-bazel wrote. Without a Bazel (`cargo::a_build_file_in_a_vendored_copy_is_a_changed_copy`), six checkouts with one build file each that the scan did not record: `BUILD.bazel` in the copy's own directory under the banner in a Bazel workspace with a crate hub, the same in a checkout that is no Bazel workspace and in a workspace whose module file makes no hub, one without the banner, one named `BUILD`, and one in `src/`. Every one is a changed copy today: `vendor --check` exits 1, `vex` leaves the patch out and writes no document, and a second `scan --mode vendored` downloads the crate again and removes the file. The scan writes no `.bazelignore` in any of them. `vex` of the flows writes its document beside the checkout through `Cell::document`, which needs no Bazel, so the hermetic test shares it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
In a Bazel workspace with a rules_rust crate hub, the build after `scan --mode vendored` is the patched one, and from rules_rust 0.59.0 on the hub's tool, cargo-bazel, writes a `BUILD.bazel` into the vendored copy under `.socket/vendor/cargo/<uuid>/<crate>/` each time Bazel evaluates the hub. Two things went wrong with that file, right after a patched and green build: - The scan recorded no such file, so every check of the copy against the ledger's inventory took it for a changed one (`vendor_inventory_mismatch`): `vendor --check` exited 1, `vex` left the patch out and wrote no document, and the next vendored scan downloaded the crate again. - Bazel read the file as a package of the user's workspace. For a crate with a dependency that package names a repository only the hub sees, and `bazel cquery //...` and `bazel query 'deps(//...)'` failed on it. Both are fixed where the workspace has such a hub, and nowhere else: `MODULE.bazel` at the Bazel root, or a file it includes, calls `from_cargo` on the extension `crate` of rules_rust's `//crate_universe:extensions.bzl` (or `extension.bzl`, its older name). `bazel::cargo_bazel::hub` reads that with the reader the VEX step uses. The file is no change of the copy The inventory check of a Cargo copy in its place leaves that one file out. It is the file when all of this holds: - a regular file named `BUILD.bazel` in the copy's own directory that the inventory does not list. A build file the crate ships is listed and stays held to the crate's bytes; - it starts with the banner of every file cargo-bazel renders (a line of `#`, `# @generated`, and a line that starts with `# DO NOT MODIFY: This file is auto-generated by a crate_universe tool.`; the template is the same from rules_rust 0.56.0 to 0.75.0); - the project is in a Bazel workspace with a crate hub. In any other project the file is a changed copy, as before. Every recorded file is still compared and any other unrecorded file still fails. `verify_vendored_patch_record` is the one check behind `vendor --check`, `vex`, `repair` and the re-run of a vendored scan, so all four follow: the check passes, `vex` attests the crate, `repair` restores nothing, and a second scan reports the copy `already_vendored` without a download. The exemption is made there, on the files found in the copy, and `verify_dir_inventory`, which also holds a download staged for a copy, compares as before. Only the banner is read. The rest of the file differs from one machine and ruleset release to the next (the command that renders it again, the platforms, the labels of the dependencies), and a hub can add text of the user's own to it, so nothing recorded could be compared with it. So a build file of someone else's under the same banner passes `vendor --check`. It does not reach the crate, because the hub copies the directory into a repository of its own and renders the build file there again (`local_crate_mirror.bzl`): the build still prints the patched marker. Bazel is kept out of the copies `bazel::ignore::sync`, which keeps a `.bazelignore` line for the Go module copies under `.socket`, keeps one for `.socket/vendor/cargo` too, under a comment line of its own (`# socket-patch: patched crate copies, not Bazel packages (to opt out, comment out the next line)`). Every command that can write or remove a vendored copy already ends there, so `scan --mode vendored` writes the pair and `vendor --revert` takes it away, and the rules of the Go lines hold: nothing is added for a directory a line already covers, a commented-out path line is the user's "no", a file that cannot be written is the warning `bazelignore_not_updated`, and a run whose `--ecosystems` leaves `cargo` out adds none. The call now takes the two ecosystems apart and says whose lines changed, so a person reads `patched crate copies` or `patched Go module copies` in the line that reports the file. The detail of the warning speaks of patched copies and names `bazel cquery //...` beside the two commands it named. With the line the copy is no package: `//...` is the user's own targets, `bazel cquery //...` and `bazel query 'deps(//...)'` pass, and a build file that someone else puts into a copy is no package either. The build is the same patched one, because the hub reads the copy by its path. Why only under a hub in the module files: rules_rust's `crates_vendor` in local mode names a path crate by its package in the checkout (`rendering.rs`, `make_deps`; read, not run). There the file in the copy is what the crate is built from, and a line would take the crate out of the build. A hub of the older `WORKSPACE` system is not looked for either. In such a workspace nothing changes: no line, and the file is a changed copy. Not covered: a crate that ships a `BUILD.bazel`. cargo-bazel writes over it (`write_outputs`; read, not run), and the copy reads as changed after a build, as before. Tests The vendored flow on real Bazel loses its three known gaps. The scan writes the `.bazelignore` pair among its files. Right after the build `vendor --check` passes and `vex` attests the crate with either ruleset, `//...` is the consumer alone, and the two commands that analyse every target pass. With the path line commented out, as a user who declines it has it, the package is back where the ruleset writes the file, and both commands fail on the repository of the dependency. `vendor --revert` takes the pair away with the copy. On a second machine the second scan downloads nothing and changes no file; the file under someone else's banner passes the check and is no package under the line, and with the line commented out `bazel build //...` builds its target; the changed library is still `vendor_hash_mismatch`. Without a Bazel, of the six build files of the earlier commit only the first is no change of the copy; the five others, the workspace without a hub among them, are the changed copies they were, and `repair` after the scan restores nothing in any of them. A second test holds the line: written under a hub and not without one, not added by a run that leaves Cargo out, declined by a commented-out path line, removed with the copies, and reported to a person in its own words. Unit tests hold the hub lookup, the predicate and the check, one difference per row, and the pair of the crates in `sync`. The cap of the `bazel` group in `scripts/loc-budget.json` follows the code (2486 to 2552). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A review of the change found that it accepted more, and wrote more, than it had shown to be safe. The acceptance. `vendor --check`, `vex`, `repair` and a repeated vendored scan left an unrecorded `BUILD.bazel` under cargo-bazel's banner out of the comparison wherever the workspace had a crate hub. Only the banner is read, so a file that someone else puts into a vendored copy under that banner passed too, and without a `.bazelignore` line over the copy (a checkout vendored by an earlier release, a file that could not be written, the user's opt-out) Bazel reads that file as a package and `bazel build //...` builds its targets. The file is now let through only in a copy that a line of the root's `.bazelignore` covers, where it is no package. Without the line it is the changed copy it was before this change. The hub. Any `crate.from_cargo` call counted, so the `.bazelignore` pair was written, and the file accepted, for a call in a comprehension or behind a condition, and for the hub of another Cargo workspace of the checkout, which writes nothing into this project's copies. A hub of the project's crates is now a call that is a statement of its own and names the project's `Cargo.lock` as `cargo_lockfile`, or its root `Cargo.toml` among `manifests`, by a label of the main repository written out as a string. Anything else leaves the copies and the file as they are. Smaller things from the same review: - a human run that changed the Go lines for one project and the crate lines for another under the same Bazel root printed only the first message; each kind of copy is now named; - the module files are read only when a pair for the crates is about to be added, not on every command of a project with vendored crates; - the row of the crates in the table of directories says that it is theirs, where the loop compared a string, and `sync` hands back the kinds of copy whose lines changed, not a joined phrase; - one definition of `.socket/vendor/cargo` (`CARGO_VENDOR_DIR`). The docs say where the Bazel root is not found (a submodule, a checkout of another user): both parts are off there. Not changed, and still as the description says: a workspace with both a hub and a `crates_vendor` target in local mode over the same Cargo workspace, and a crate that ships a `BUILD.bazel` of its own. Each needs a build on real Bazel first. The Cargo flows pass on Bazel 9.3.2 with rules_rust 0.75.0; the vendored flow now also holds that with the path line commented out `vendor --check` exits 1, for the file cargo-bazel wrote and for a planted one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview A new
E2E and unit tests cover vendored Bazel flows, hub edge cases, and banner/ignore rules; fixture Reviewed by Cursor Bugbot for commit 1e3fd30. Configure here. |
In a Bazel workspace with a rules_rust crate hub, a vendored crate no longer breaks
bazel cquery //...andbazel query 'deps(//...)', andvendor --check,vex,repairand a repeatedscan --mode vendoredno longer take the crate for a changed one after a build has written itsBUILD.bazelinto the copy.Three commits on
main(e6c5f50); nothing this builds on is still open. The first commit is tests only and passes on main's product code. The second is the change. The third narrows it after a code review; this description is of the three together.Decisions for the maintainer
.bazelignorefor.socket/vendor/cargo, in workspaces whose module files declare acrate.from_cargohub of the project's crates. They follow the rules of the Go lines, opt-out included..bazelignoreline that covers the copy, aBUILD.bazelunder cargo-bazel's banner is not compared, whoever wrote it. There it does not reach the crate and is no package of the workspace. Without the line it is a changed copy, as on main.crates_vendorin local mode was read, not run. What this description says of it is from the rules_rust 0.75.0 source. This change does nothing for it.The full list, with the alternatives, is at the end.
What the code does today
Vendored mode keeps a patched crate under
.socket/vendor/cargo/<uuid>/<crate>/and points a[patch.crates-io]path entry at it. Under a rules_rust crate hub (crate.from_cargo) the next build is the patched one. From rules_rust 0.59.0 on, the hub's tool, cargo-bazel, also writes aBUILD.bazelinto that copy each time Bazel evaluates the hub: it renders the build file of every crate a Cargo workspace takes from a path to<path>/BUILD.bazel(crate_universe/src/rendering.rs,render_build_files).Right after a patched and green build with rules_rust 0.75.0:
socket-patch vendor --checkexits 1 (vendor_inventory_mismatch): the scan recorded no such file;socket-patch vexleaves the patch out and, with nothing else to attest, exits 1 and writes no document;scan --mode vendoreddownloads the crate again and removes the file, and the next evaluation of the hub writes it back;bazel cquery //...andbazel query 'deps(//...)'fail. Bazel reads the file as a package of the workspace, and that package names a repository only the hub sees (No repository visible as '@crates__<dependency>' from main repository).bazel build //...andbazel query //...pass.The first commit holds all four on real Bazel as known gaps. With rules_rust 0.56.0, which the fixture uses on Bazel 7.7.2, a build writes no file and none of the four happens.
What changes
Both parts apply only where the Bazel workspace has a hub of the project's crates:
MODULE.bazelat the Bazel root, or a file it includes, callsfrom_cargoon the extensioncrateof@rules_rust//crate_universe:extensions.bzl(or ofextension.bzl, its older name), the call is a statement of its own, and it names the project'sCargo.lockascargo_lockfileor the project's rootCargo.tomlamongmanifests, by a label of the main repository written out as a string. A call in a comprehension or behind a condition, one that names its files through a constant, and the hub of another Cargo workspace of the checkout are not such a hub. In every other project, inside a Bazel workspace or not, nothing changes.The two parts are given here in the order of the first two commits. They depend on each other: the file of part 1 is accepted only under a line of part 2.
1. The build file is no change of the copy. The inventory check of a Cargo copy in its place leaves that one file out of the comparison when all of this holds:
BUILD.bazelin the copy's own directory, and the inventory does not list it. A build file the crate ships is listed and stays held to the crate's bytes;#, the line# @generated, and a line that starts with# DO NOT MODIFY: This file is auto-generated by a crate_universe tool.The template is byte for byte the same at rules_rust 0.56.0, 0.59.0, 0.65.0 and 0.75.0;.bazelignorecovers the copy: the line of part 2, or one of the user's own for the directory or one above it.Every recorded file is still compared and any other file the scan did not record still fails. One function is behind
vendor --check,vex,repairand the re-run of a vendored scan (verify_vendored_patch_record), so all four follow. The check that holds a download staged for a copy is the code main has, untouched.2. Bazel is kept out of the copies. socket-patch already keeps
.bazelignorelines for the Go module copies under.socket. It now keeps one for.socket/vendor/cargoas well, under a comment line of its own:scan --mode vendoredwrites the two lines andvendor --reverttakes them away. Every rule of the Go lines holds: the file is the one at the Bazel root and the path is from that root; nothing is added where a line already covers the directory; a path line the user commented out is never touched again; a file that cannot be written is the warningbazelignore_not_updated; a run whose--ecosystemsleavescargoout adds no line. No command gained a call: every command that can write or remove a vendored copy already ends in the one helper.With the line the copy is no package:
//...holds the user's own targets, both commands pass, and the build is the same patched one, because the hub reads the copy by its path, copies the directory into a repository of its own and renders the build file there again (crate_universe/private/local_crate_mirror.bzl).Output. A person is told when the lines change, in the existing line of that helper:
Updated <path>: the lines that keep patched crate copies under .socket out of Bazel's packages, orRemoved <path>: no patched crate copy is left under .socket. The Go lines read as before. The detail ofbazelignore_not_updatednow saysthe patched copiesand namesbazel cquery //...among the commands that can otherwise fail; that wording changes for Go too. No JSON field, event or code is new.How narrow the acceptance is, and what it leaves unchecked
Only the banner is read. The rest of the file differs from one machine and one ruleset release to the next (the command that renders it again, the platforms, the labels of the dependencies), and a hub can add text of the user's own to it, so nothing recorded could be compared with it.
So a build file that someone else puts into the copy under the same banner is not told apart from cargo-bazel's. That is why the acceptance needs the
.bazelignoreline. The vendored flow holds what such a file can do, on real Bazel:vendor --checkpasses.bazel build //...builds its target, andvendor --checkexits 1 withvendor_inventory_mismatch.The price: without the line, cargo-bazel's own file is a changed copy again, as on main. That is the case for a user who commented the line out, for a file socket-patch could not write (
bazelignore_not_updated), and for a checkout vendored by an earlier release until a command that writes the line has run there (scan --mode vendored,repair,apply).In a workspace without a hub of the project's crates such a file is a changed copy, as on main.
Why only under a hub in the module files
rules_rust's
crates_vendorin local mode names a path crate by its package in the checkout (rendering.rs,make_deps). That was read in the 0.75.0 source and not run. There the file in the copy is what Bazel builds the crate from, so accepting it would leave a build-affecting file unchecked, and a.bazelignoreline would take the crate out of the build. A hub of the olderWORKSPACEsystem (crates_repository) is not looked for either. For both, this change does nothing.Contents
crates/socket-patch-core/src/bazel/cargo_bazel.rs(new): the banner, the hub lookup, the predicate, with their unit testscrates/socket-patch-core/src/bazel/ignore.rs: the pair for the crates, each ecosystem's scope, whose lines changed, whether a line covers a copy; unit testscrates/socket-patch-core/src/vendor/verify.rs: the exemption where a copy is verified in its place; unit testcrates/socket-patch-cli/src/commands/mod.rs: the commands' one.bazelignorehelpercrates/socket-patch-core/src/bazel/mod.rs,vendor/cargo_config.rscrates/socket-patch-cli/tests/e2e_bazel_build/cargo.rs: the two flows and three tests without Bazelcrates/socket-patch-cli/tests/fixtures/bazel/rules_rust/bzlmod/common/Cargo.lock: the dependencydocs/ecosystems.md,crates/socket-patch-cli/CLI_CONTRACT.mdscripts/loc-budget.json: the cap of thebazelgroup follows the codeThe
bazelgroup grows by 105 lines of code byscripts/loc-budget.py(66 in the second commit, 39 in the third);verify.rsadds 17 and the CLI helper about 10 outside it. In all: 11 files, +1435 / -256. No workflow changes.The fixture's crate gets a dependency, a second crate that the tests' stand-in registry serves. Without one, the build file cargo-bazel writes names no repository of the hub and the two failing commands could not be a committed test. The hosted flow builds the same crate and its expectations are unchanged.
What it proves, and where
All runs on macOS arm64. The third commit changed the product and the tests, so each paragraph says at which head its runs were made: "the second commit" is c09af56, "the head" is the third.
Real Bazel, as the reusable workflow's run step runs the Cargo leg (the tests whose names start with
cargo::, two at a time, a fresh output root per run):Bazel 8.8.2 and 7.7.2 have not run the third commit; CI runs them.
The vendored flow has no known gap left. The scan's files include
.bazelignorewith the pair. After the build,vendor --checkpasses andvexattests the crate with either ruleset;//...is the consumer alone andbazel cquery //...andbazel query 'deps(//...)'pass. With the path line commented out, on 9.3.2 and 8.8.2//...holds two targets in the copy, both commands fail on the repository of the dependency and (at the head, on 9.3.2)vendor --checkexits 1; on 7.7.2, where no file is written, all three pass.vendor --reverttakes the pair away with the copy. On a second machine a second scan downloads nothing and changes no file. A changed library is stillvendor_hash_mismatch.The first commit on main's product code: its tests without Bazel pass, and its two flows pass on Bazel 9.3.2 with the known gaps as they are, the two failing commands among them. The Bazel run was made on the two earlier states of main this branch was based on during the work; after the last rebase onto e6c5f50 only its tests without Bazel were run again.
With the product change taken out, the vendored flow fails on Bazel 9.3.2 at its first assertion about the scan's files, and two of the three Cargo tests without Bazel fail.
Without Bazel:
cargo::only_the_build_file_of_cargo_bazel_is_no_change_of_a_vendored_copy: eight vendored checkouts with one unrecorded build file each. Only cargo-bazel's file in a workspace with a hub of the project's crates, under the line of the scan, is no change. In a checkout that is no Bazel workspace, in a workspace whose module file makes no hub or the hub of another Cargo workspace, with the path line commented out, without the banner, namedBUILD, or insrc/, the copy is the changed one it was.cargo::the_vendored_crates_get_a_bazelignore_line_where_a_crate_hub_builds_them: the pair is written under a hub of the project's crates, and not without one or under the hub of another Cargo workspace; a run that leaves Cargo out adds none; a commented-out path line stays as it is over a scan and a repair, with no warning;vendor --revertremoves the pair from a file that keeps the user's line; a person is told in the crate wording.Unit tests: the hub lookup (the tag, both file names, another name for the ruleset, an included file; either Cargo file, under each spelling of the main repository; the files of another Cargo workspace or repository, files named through a constant, a call behind
andor in a comprehension; a project below the root), the predicate (each banner line, from the start of the file; with and without a.bazelignoreline that covers the crate), the check (one difference per row; a second file, a build file in a sub-directory or a changed recorded file beside the accepted one; no line, a commented-out line, a line for another directory, a line for a directory above; a link of that name; a build file the crate ships; a crate that ships module files of its own in a project without Bazel), and the pair of the crates insync. Seventeen mutations of the second commit's product code, one condition each, were each caught there: sixteen by the unit tests, one by the test without Bazel. At the head, three more of the new rules (the line, the statement of its own, the named files) are each caught by the unit tests.Nothing changes without a hub: a binary built from main's product code and one from this branch were run in the same vendored Cargo checkout, in four checkouts (no workspace file;
MODULE.bazelwithout a hub; a hub's module file beside the project;MODULE.bazelwith the hub), fourteen shapes of the copy and eight commands (vendor --check,vex,scan --mode vendored,repair,vendor,list,apply,vendor --revert), each with--jsonand without. Of 448 comparisons the 336 in the three checkouts without a hub are the same in exit codes, both streams, the VEX document and every file left. The 18 that differ are in the checkout with the hub: the build file under the banner for the first four commands, andvendor --revertin each shape, which removes the.bazelignorepair. This comparison was made at the second commit and not repeated at the head: the third commit only narrows where the two parts apply, and its tests without Bazel hold the checkouts without a hub to main's behaviour.Suites at the head: clippy for the workspace and for the real-Bazel test target;
cargo checkof every target; the unit tests ofbazel::(128) andvendor::verify(26); the CLI targetsvendor,repair,vex,cliandspawn_env_hygiene;e2e_bazel_buildwithout Bazel (51); the script tests. At the second commit: the core unit suite (8342 tests) and its 32 integration targets; the CLI unit suite; twenty CLI targets that reach the changed code (vendor,repair,scan,vex,apply,rollback,remove,get,scan_vendor_e2e,in_process_vendor,in_process_rollback_vendored,in_process_remove_repair_lifecycle,vendor_revert_tamper_e2e,mode_migration_cargo,e2e_vex_lockfile,e2e_vex_vendor,e2e_vendor_cargo_build,e2e_vendor_gem_build,e2e_vendor_golang_build,e2e_golang_build),cli,spawn_env_hygiene,e2e_bazel_buildwithout Bazel, and the script tests. No existing expectation changed. Two tests ofe2e_vendor_cargo_builddid not run to their assertions here: they start x86_64 toolchains from 2020, which this machine cannot execute. CI runs them.Code review
/code-review highon the first two commits gave nine findings. Each was confirmed by reading the code. Seven are fixed in the third commit, two are not.Fixed:
.bazelignoreline. A plantedBUILD.bazelunder the banner passedvendor --checkandvexwhile Bazel read it as a package, wherever the line was missing: a checkout vendored by an earlier release, a file that could not be written, the opt-out. The file is now let through only in a copy that a line covers.from_cargocall counted as a hub. One in a comprehension or behind a condition, and the hub of another Cargo workspace of the checkout, got the line and the acceptance. A hub is now a call that is a statement of its own and names the project'sCargo.lockor rootCargo.tomlby a written-out label.synchanded back a joined phrase. The row now says it is the crates', andsynchands back the kinds of copy..socket/vendor/cargo. One now.vendor --checkandvexwithout the docs saying so. The docs now name the cases (see "Not covered").Not fixed:
crates_vendortarget in local mode over the same Cargo workspace. The line would take the crate out of that vendor target's build. This is known from the ruleset's source, not from a build, and finding such a target means reading every BUILD file of the workspace. It stays the documented case in which the user comments the line out; with the third commit, cargo-bazel's file is then a changed copy there, which is right where that file is what the crate is built from.BUILD.bazelof its own. By the ruleset's source cargo-bazel writes its file over the crate's, and the copy then reads as changed after a build, as on main. Accepting a recorded file that was replaced needs a build on real Bazel with such a crate first.Not covered
crates_vendor(local or remote mode) and aWORKSPACE-eracrates_repositoryhub: neither was run on real Bazel. What is said of them is from the rules_rust 0.75.0 source, and this change does nothing for them.crate.from_cargohub and a local-modecrates_vendortarget over the same Cargo workspace. The line is written there and, by the source, would take the crate out of that vendor target's build. Such a workspace must comment the line out; the docs say so. Nothing detects it..gitbelongs to the user, to root or to the usersudoran for. In a submodule, or in a checkout a CI container mounts from another user, both parts are off, andvendor --checkfails after a build there although it passes on a developer's machine. The docs say so.BUILD.bazelof its own. By its source (write_outputs), which no build here has run for such a crate, cargo-bazel writes its file over that one. The inventory lists the crate's file, so the copy reads as changed after a build, as before, until a second scan orrepairrestores it.glob()of a package above it. A target that hands the project's files to acargoof its own through such a glob no longer receives the copies. From rules_rust 0.59.0 on, cargo-bazel's own file in the copy has the same effect. Not measured for Cargo.The decisions in full
.bazelignorefor vendored crates wherever the module files declare acrate.from_cargohub. The alternative is to document the line and leave the two commands failing after every build.vendor --check: aBUILD.bazelunder cargo-bazel's banner, in a workspace with a hub of the project's crates, in a copy that a.bazelignoreline covers. It does not change what the crate is built from, and under the line it is no package. The other choices are to leave the check failing after every build, or to record the file's hash at the first check after a build, which is a second piece of state for a file that differs per machine.crates_vendorandWORKSPACEhubs. They stay as on main: no line, and the check fails after the ruleset writes its file. Extending either part to them needs a build on real Bazel with each first.BUILD.bazel. Accepting a recorded build file that cargo-bazel replaced is a few lines. It needs a build on real Bazel with such a crate first.bazelignore_not_updatedis now the same sentence for Go and Cargo copies.🤖 Generated with Claude Code