-
Notifications
You must be signed in to change notification settings - Fork 505
Description
When a user has listed a finite, static set of Cargo.toml
files in a bzlmod
setup, rules_rust
still seems to scan for Cargo.toml
files quite aggressively when initializing the rules. Per this comment there seems to be a requirement for identifying new Cargo.toml
files. Although this is an understandable requirement, its current implementation seems to violate a few assumptions/best practices how Bazel works.
Scanning of new files should be an explicit action like bazel mod tidy
or a specific Gazelle invocation. That's how other rules do it and it is the recommend best practice, i.e. that's where a user would expect Bazel (and rules) to do such work. But not during regular invocation for a build
or test
or query
.
Original Discussion:
I am setting up rules_rust in a bzlmod workspace.
In my MODULE.bazel
I list the Cargo.toml
files explicitly.
# Rust toolchain
bazel_dep(name = "rules_rust", version = "0.61.0")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2024",
versions = ["1.85.0"],
)
# Crate Universe dependencies
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.from_cargo(
name = "crates",
cargo_lockfile = "//:Cargo.lock",
manifests = [
"//:Cargo.toml",
"//foo/cli:Cargo.toml",
"//bar/lib:Cargo.toml",
],
supported_platform_triples = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
],
)
use_repo(crate, "crates")
When I run bazel mod deps
(or some other Bazel command) it fails with:
Error: Failed to splice workspace
Caused by:
0: Failed to walk filesystem finding workspace Cargo.toml files
1: IO error for operation on ../data/postgres/16: Permission denied (os error 13)
2: Permission denied (os error 13)
This is expected. The data
directory is listed in .bazelignore
. It's also not listed in Cargo.toml
.
Why is rules_rust
trying to scan for Cargo.toml
files? I listed all I want explicitly in the manifests
list. Is there a way to exclude the data
folder from scanning?