bazelbuild / bazelbuild/rules_rust

replace crate_universe with a gazelle plugin?

Open
#2,895 2 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

We have a monorepo that has hundreds of crates in it. Using current crate_universe rules is painful in different ways:

- [crates_repository](https://bazelbuild.github.io/rules_rust/crate_universe.html#crates_repository)
- frequent and painfully slow splicing/repinning given that cargo touches `Cargo.lock` whenever someone adds a in-repo dep in their crate.
- never a clean git merge/revert given the `checksum` in `cargo-bazel-lock.json` is not patchable
- [crates_vendor](https://bazelbuild.github.io/rules_rust/crate_universe.html#crates_vendor) in remote mode
- no more waiting on splicing/repining
- clean git merge/revert at most of the time
- unreadable `defs.bzl` in the generated `vendor_path` dir
- slow calls to [`all_crate_deps`](https://bazelbuild.github.io/rules_rust/crate_universe.html#all_crate_deps) in BUILD files
- chicken and egg issue after creating a new crate
1. one must export `Cargo.toml` in the new crate for `crates_vendor` to use in `manifests` attr (separate issue)
2. NOTE: one must not add `all_crate_deps()` as the deps are not in the generated `all_crates_deps` yet, and build file eval will fail when running `crates_vendor`
3. run `crates_vendor` to regenerate `all_crates_deps`
4. update rust_library to use `all_crates_deps` again

This is way behind the UX from rules_go with gazelle.

Can we add a plugin to read `cargo metadata` output and generate all the rules directly -- for both 3rd party ones and in-repo ones. So that we can sunset most parts of the `crate_universe` and provide a unified bazel experience to users.

https://github.com/Calsign/gazelle_rust has a gazelle plugin for rust but seems a little bit over-engineered.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.