bazelbuild / bazelbuild/rules_rust

Generating `Cargo.Bazel.lock` doesn't work with workspace dependencies in nested subcrates

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

Description

(First off thank you all so much for developing these Bazel rules! I'm really excited to start using Bazel in my company's Rust codebase.)

I have a few instances of crates nested in other crates, like so:

```
$ tree
.
├── BUILD.bazel
├── Cargo.Bazel.lock
├── Cargo.toml
├── WORKSPACE
└── serialization
├── Cargo.toml
├── macros
│ ├── Cargo.toml
│ ├── cargo
│ └── src
│ └── lib.rs
└── src
└── lib.rs
```

When I try to update the `Cargo.Bazel.lock` file with e.g. `CARGO_BAZEL_REPIN=true bazel test //...`, I get:

```
Error: Failed to generate context digest

Caused by:
0: Failed to load manifest '[...]/serialization/macros/Cargo.toml'
1: workspace dependencies are missing `quote`
```

The relevant part of `.../firmware-shared/serialization/macros/Cargo.toml` is:

```
[dependencies]
quote = {workspace = true}
syn = {workspace = true, features = ["full"]}
```

But these dependencies are in fact listed in the workspace `Cargo.toml` file:

```
[workspace.dependencies]
[...]
quote = "1.0"
```

I'm guessing that Crate Universe is thinking that `serialization/Cargo.toml` -- the crate within which `serialization/macros` is nested -- is the workspace `Cargo.toml` file, when in fact it isn't.

For now I made all nested-crate dependencies explicit rather than using workspace dependencies, but would love for Crate Universe to handle this! Please let me know how I can help!

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.