bazelbuild / bazelbuild/rules_rust
"Fetching module extension" taking a long time to complete
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
**EDIT:** If you're facing this issue, I recommend using [vendored crates](https://bazelbuild.github.io/rules_rust/crate_universe_bzlmod.html#vendored-dependencies).
Hey folks,
We have a large monorepo comprising of 357 crates. We recently switched to `bzlmod` to avoid very frequent issues with `Cargo.bazel.lock` merge conflicts, and in that regard the transition went great.
However, we're now seeing the `Fetching module extension crate in @@rules_rust~//crate_universe:extension.bzl; starting` step taking from a minimum of 20s to upwards of two minutes. This runs on any `bazel build` or `bazel mod deps --lockfile_mode=update` provided one or more `Cargo.toml` declared in the `manifests` key of `.from_cargo` is `touch`ed, which occurs very frequently.
Is there a way we could speed up this step in our configuration?
This is our `MODULE.bazel` file:
```
bazel_dep(name = "rules_rust", version = "0.50.1")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
extra_target_triples = [
"aarch64-apple-ios-sim",
"aarch64-apple-ios",
"aarch64-linux-android",
"x86_64-unknown-linux-gnu",
"x86_64-apple-ios",
"wasm32-unknown-unknown",
],
versions = ["nightly/2024-08-23"],
)
use_repo(
rust,
"rust_toolchains",
)
register_toolchains("@rust_toolchains//:all")
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
crate.from_cargo(
name = "crates",
cargo_lockfile = "//rs:Cargo.lock",
manifests = [
"//rs:Cargo.toml", # Workspace Cargo.toml
# ... 300+ crates
],
)
crate.annotation(
crate = "rdkafka-sys",
gen_build_script = "off",
)
crate.annotation(
crate = "log",
# Needed to completely disable debug logs in release mode
crate_features = ["max_level_trace", "release_max_level_info"],
)
use_repo(crate, "crates")
```
Contributor guide
Assessment
This issue has not been assessed yet.