bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
623 stars 398 forks source link

Broken build dependency #1966

Open fmorency opened 1 year ago

fmorency commented 1 year ago

Probably related to #1850 and #1884

MRE: https://github.com/fmorency/bazel-broken-dep

Works on rules_rust 0.17.

The serde* build-dependencies are not propagated correctly causing the Bazel build to fail.

Works with cargo.

Tested with Bazel 6.0.0 and 6.1.2.

UebelAndre commented 1 year ago

Hi, what aren't they correctly propagated to? Can you make this issue a bit more descriptive?

And it broke after 0.17? or within the range of 0.17 to latest?

UebelAndre commented 1 year ago

The issue appears to come from gherkin where the serde dependency is optional in dependencies but not build-dependencies (see Cargo.toml).

fmorency commented 1 year ago

You are correct, the serde dependency is not propagated to gherkin resulting in a build failure. As you already noticed, serde is optional in dependencies but not in build-dependencies.

I was wrong, the project builds fine with rules_rust <= 0.20.0. It starts breaking with rules_rust == 0.21.0.

I updated the MRE to reflect this.

UebelAndre commented 1 year ago

I think this issue lies somewhere in https://github.com/bazelbuild/rules_rust/blob/0.21.1/crate_universe/src/metadata/dependency.rs#L149-L180

If the same dependency exists in dependencies and build-dependencies, it seems only one is considered. If you're willing to work on a pull-request to fix this I'm happy to review and help how I can 😄