Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crate_universe ignores dependencies between workspace members #2994

Open
KoltesDigital opened this issue Nov 12, 2024 · 0 comments
Open

crate_universe ignores dependencies between workspace members #2994

KoltesDigital opened this issue Nov 12, 2024 · 0 comments

Comments

@KoltesDigital
Copy link

KoltesDigital commented Nov 12, 2024

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 <output_base>/external/rules_rust~~crate~crates/defs.bzl has the following:

...
###############################################################################
# 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant