bazelbuild / bazelbuild/rules_rust

Leftover rust-analyzer specs can cause generation to fail

Open
#2,774 1 comment 1 reaction 0 assignees View on GitHub
bug expert-needed help wanted rust-analyzer workaround
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

I ran into a odd situation where after running `bazel run @rules_rust//tools/rust_analyzer:gen_rust_project` I got an error
```
Error: Failed to make progress on building crate dependency graph
```

However, I was confused because on a different machine (same code and commit) the tool worked just fine. After running
```bash
RUST_LOG=debug bazel run @rules_rust//tools/rust_analyzer:gen_rust_projec
```
and diffing logs from the working machine and broken machine, I noticed the working machine had
```
[WARN gen_rust_project_lib::aquery] Skipping missing crate_spec file: ....
```
but the broken machine didn't have this log and instead had
```
[DEBUG gen_rust_project_lib::aquery] CrateSpec {crate_id: "ID-external/....." }
```

This lead me to the following code which suggests that any leftover outputs from other configurations might impact generating `rust-project.json` and lead to the failure above
https://github.com/bazelbuild/rules_rust/blob/64deada6142c28b20028f81c26ba536eba80d828/tools/rust_analyzer/aquery.rs#L148-L152

The "solution" was to run `bazel clean` and retry generating `rust-project.json`. This solution is not acceptable to me and should be considered a big. The tool should behave consistently even if there's some leftover files in `bazel-out/`.

I don't yet have a consistent repro but hoping someone else does 😅. Either way, thought this info would be useful.

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.