Description
When I run
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
in my Bazel/Rust project, the generated rust-project.json
contains an entry for an code-generated crate, but the path in root_module
of the crate entry does not exist. Removing the rust_project.json
and re-running it doesn't fix it. I have tried disabling the disk_cache, but the command above still generates the wrong root_module
.
This is an example output
{
"sysroot": "/home/wvhulle/.cache/bazel/_bazel_wvhulle/2f024897ff0f2736b273e0e86d0d74ec//external/rules_rust~~rust~rust_analyzer_1.80.0_tools",
"sysroot_src": "/home/wvhulle/.cache/bazel/_bazel_wvhulle/2f024897ff0f2736b273e0e86d0d74ec/external/rules_rust~~rust~rust_analyzer_1.80.0_tools/lib/rustlib/src/library",
"crates": [
{
"display_name": "middleware_messages",
"root_module": "/home/wvhulle/.cache/bazel/_bazel_wvhulle/2f024897ff0f2736b273e0e86d0d74ec/execroot/_main/bazel-out/k8-fastbuild/bin/otiv3/middleware_types/middleware_messages.lib.rs",
"edition": "2021",
"deps": [],
"is_workspace_member": true,
"cfg": [
"test",
"debug_assertions"
],}]}
The file /home/wvhulle/.cache/bazel/_bazel_wvhulle/2f024897ff0f2736b273e0e86d0d74ec/execroot/_main/bazel-out/k8-fastbuild/bin/otiv3/middleware_types/middleware_messages.lib.rs
does not exist although the target can be build without problem.
I have tried to disable the disk cache completely, removing the disk cache at ~/.cache/bazel
completely and also changing the location with --disk_cache=~/.cache/bazel_disk_cache
.
It seems like the wrong path is generated pointing to a non-existing location in the cache. Sometimes it suddenly works, but often it is just broken and I don't understand why.