bazelbuild / bazelbuild/rules_rust
Crates Universe: The optional-only dependency is not fetched even if needed
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I’m trying to build a rust binary, that has some optional dependencies in the Cargo.toml, for my configuration I want to use these optional dependencies.
But it looks like the optional dependencies are not even fetched, and not added to the “@crate_index” repository.
That means that even if I specify them explicitly in the rust_binar binary:
```
rust_binary(
name = "gui",
srcs = glob(["src/**/*.rs"]),
deps = all_crate_deps() + [
"@crate_index//:astc-decode",
],
)
```
they can not be used:
```
ERROR: /Users/evgenypetrov/work/bazel_playground/rust/gui/BUILD.bazel:5:12: no such target '@crate_index//:astc-decode': target 'astc-decode' not declared in package '' defined by /private/var/tmp/_bazel_evgenypetrov/0e70737357a2a67453272d7916c8876e/external/crate_index/BUILD.bazel (Tip: use `query "@crate_index//:*"` to see all the targets in that package) and referenced by '//rust/gui:gui'
ERROR: Analysis of target '//rust/gui:gui' failed; build aborted: Analysis failed
```
Here is the repo, that reproduces the problem
https://github.com/golovasteek/bazel_playground/blob/6f2ade625c80a73a0fcdfc8f936cd46963674454/rust/gui/BUILD.bazel
Contributor guide
Assessment
This issue has not been assessed yet.