bazelbuild / bazelbuild/rules_rust

No matching toolchain when trying to run rust_analyzer

Open
#2,160 1 comment 0 reactions 0 assignees View on GitHub
needs-triage rust-analyzer
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

I have `rust_register_toolchains()` in my `WORKSPACE`, and I've also tried `register_toolchains(rust_analyzer_toolchain_repository())`, but trying to run `rust_analyzer` like

```sh
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
```

gives this error

```
ERROR: Analysis of aspects '[@rules_rust//rust:defs.bzl%rust_analyzer_aspect] with parameters {} on //target' failed; build aborted: No matching toolchains found for types @rules_rust//rust:toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@rules_rust//rust:toolchain_type'
```

Running with the suggested debug argument, it looks like a toolchain is indeed identified (I've removed rejected toolchains from the output):

```
INFO: ToolchainResolution: Target platform //linux_x86: Selected execution platform //linux_x86, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @llvm_toolchain//:cc-clang-x86_64-linux, type @rules_rust//rust:toolchain_type -> toolchain @rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain
INFO: ToolchainResolution: Target platform //linux_x86: Selected execution platform //linux_x86, type @rules_rust//rust/rust_analyzer:toolchain_type -> toolchain @rust_analyzer_1.72.0_tools//:rust_analyzer_toolchain, type @rules_rust//rust:toolchain_type -> toolchain @rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain
INFO: ToolchainResolution: Target platform //linux_x86: Selected execution platform //linux_x86, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @llvm_toolchain//:cc-clang-x86_64-linux, type @rules_rust//rust:toolchain_type -> toolchain @rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain
```

It would seem to me that the first INFO line here shows bazel does find a toolchain for the given type. Why doesn't `rust_analyzer_aspect` find this? Should I be concerned about some duplicate information being shown in this debug output?

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.