bazelbuild / bazelbuild/rules_rust

`crate_universe` ignores dependencies between workspace members

Open
#2,994 1 comment 3 reactions 0 assignees View on GitHub
needs-design
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

I've just upgraded the rules from 0.30.0 in WORKSPACE to 0.54.1 in bzlmod, on Windows 11. My project does not compile anymore.

The problem is that `all_crate_deps` does not list workspace siblings, whereas it used to.

I've set up a minimal reproducible example at https://github.com/KoltesDigital/bazel-rust-workspace-members . It's basically a library and a binary, the latter depends on the former. But _/external/rules_rust~~crate~crates/defs.bzl_ has the following:

```starlark
...
###############################################################################
# WORKSPACE MEMBER DEPS AND ALIASES
###############################################################################

_NORMAL_DEPENDENCIES = {
"mybin": {
},
"mylib": {
},
}
...
```

which means `all_crate_deps` in _mybin/BUILD_ does not declare a dependency to `mylib`, and thus `build` fails.

The workaround is to manually add `+ ["//mylib:library"]` to _mybin/BUILD_.

It used to work, but now that I've written the previous sentence, I'm wondering whether it was working by mistake and was never intended to. I don't know any way for `crate_universe` to know the precise target name of a library in the user project.

So, is the workaround the actual way to go? If so, you may consider integrating my example into _examples/bzlmod_ to let people know.

Update: well... even the workaround doesn't work. Build still fails! What should I do?

Update 2: workaround works when targets are named exactly like the crates. Check branch `works` out.

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.