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

rust-project.json points to non-existing file #2991

Open
otiv-willem-vanhulle opened this issue Nov 7, 2024 · 1 comment
Open

rust-project.json points to non-existing file #2991

otiv-willem-vanhulle opened this issue Nov 7, 2024 · 1 comment

Comments

@otiv-willem-vanhulle
Copy link

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.

@otiv-willem-vanhulle
Copy link
Author

I seem to make some progress if remove all disk cache options from .bazelrc: common --disk_cache=~/.cache/bazel_disk_cache. It seems like there is a bug that causes the rust-project.json not to detect the usage of an alternative disk_cache. When I don't specify the cache and start from a clean state, things seem to work at first sight.

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