Skip to content

No matching toolchain when trying to run rust_analyzer #2160

Open
@xander-zitara

Description

@xander-zitara

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

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions