bazelbuild / rules_rust

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

gen_rust_project error : Error: Failed to make progress on building crate dependency graph #2306

Open rbtcollins opened 11 months ago

rbtcollins commented 11 months ago

I'd put more here but I haven't tried to figure this out yet (fortunately we keep the Cargo toolchain working, so Bazel is a CI optimisation, not a core developer requirement)

alexpusch commented 10 months ago

bazel clean solved this issue for me

cameron-martin commented 8 months ago

bazel clean solved this issue for me

Same. The question is, why?

rbtcollins commented 4 months ago

Setting RUST_LOG=info got me some debug (and clean doesn't solve it for me).

INFO: Running command line: bazel-bin/external/rules_rust~/tools/rust_analyzer/gen_rust_project
"/home/robertc/.cache/bazel/_bazel_robertc/8b0aece0fa823e87b78e3a123965ccb1/execroot/_main/bazel-out/linux_amd64-opt-exec-ST-b021421c07d4/bin/external/_main~crate_repositories~crates_vendor__crunchy-0.2.2/crunchy.rust_analyzer_crate_spec.json"
[2024-06-21T06:09:44Z WARN  gen_rust_project_lib::aquery] Skipping missing crate_spec file: "/home/robertc/.cache/bazel/_bazel_robertc/8b0aece0fa823e87b78e3a123965ccb1/execroot/_main/bazel-out/linux_amd64-opt-exec-ST-b021421c07d4/bin/external/_main~crate_repositories~crates_vendor__dirs-sys-next-0.1.2/dirs_sys_next.rust_analyzer_crate_spec.json"
[2024-06-21T06:09:45Z WARN  gen_rust_project_lib::rust_project] Cycle detected: ["ID-services/turbofish/gandalf-auth/src/lib.rs", "ID-services/turbofish/gandalf-buildinfo/src/lib.rs", "ID-services/turbofish/gandalf-core/src/lib.rs", "ID-services/turbofish/gandalf-metrics/src/lib.rs", "ID-services/turbofish/gandalf-test-utils/src/lib.rs", "ID-services/turbofish/gandalf-core/src/lib.rs"]
[2024-06-21T06:09:45Z WARN  gen_rust_project_lib::rust_project] Cycle detected: ["ID-services/turbofish/gandalf-buildinfo/src/lib.rs", "ID-services/turbofish/gandalf-core/src/lib.rs", "ID-services/turbofish/gandalf-metrics/src/lib.rs", "ID-services/turbofish/gandalf-test-utils/src/lib.rs", "ID-services/turbofish/gandalf-core/src/lib.rs"]

This repo builds cleanly with both native rust tools and Bazel; the cycle is not a cycle once dep type is considered.

foo-core[dev] <- foo-test-utils <- foo-core foo-metrics[dev] <- foo-test-utils <- foo-core

so the build builds foo-core, then foo-test-utils, then foo-core[dev] which picks up the tests and runs them

Not ideal, first to admit that, but it explains the failure here.

In rust-analyzer, the cycle is logged as well:

2024-06-20T13:20:07.346042Z ERROR project_model::workspace: cyclic deps: gandalf_metrics(Idx::<CrateData>(131)) -> gandalf_test_utils(Idx::<CrateData>(133)), alternative path: gandalf_test_utils(Idx::<CrateData>(133)) -> gandalf_core(Idx::<CrateData>(124)) -> gandalf_metrics(Idx::<CrateData>(131))

It would be nice to at least show more of the error than this one-line opaque message.

ikezedev commented 4 months ago

In Vs Code, Toggle Rust Analyzer in the output tab. And you will see all the cyclic dependencies warning