Skip to content

Hermetic vs system rust-analyzer. #3762

@lromor

Description

@lromor

Hi,

The rules work really well! Thanks a lot for your work.
I have a question, what do you suggest to have the editor pick the right rust-analyzer? I'm using nix and I'm noticing some errors when using the system/flake version vs the hermetic one.

No error when using (rust-analyzer 1.86.0 (05f9846 2025-03-31)):

rules_rust++rust+rust_analyzer_1.86.0_tools/bin/rust-analyzer diagnostics .

Error when using the system one (rust-analyzer 2025-10-28):

ERROR `cargo metadata` failed on `/home/<...>/.cache/bazel/<...>/e2e3cb9bf16f1c81675a0d2877a06ae9/external/rules_rust++rust+rust_analyzer_1.86.0_tools/lib/rustlib/src/library/Cargo.toml` : Failed to run `cd "/home/<...>/.cache/bazel/<...>/e2e3cb9bf16f1c81675a0d2877a06ae9/external/rules_rust++rust+rust_analyzer_1.86.0_tools/lib/rustlib/src/library" && RUSTUP_AUTO_INSTALL="0" RUSTUP_TOOLCHAIN="/home/<...>/.cache/bazel/<...>/e2e3cb9bf16f1c81675a0d2877a06ae9/external/rules_rust++rust+rust_analyzer_1.86.0_tools" __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" "cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/lromor/.cache/bazel/_bazel_lromor/e2e3cb9bf16f1c81675a0d2877a06ae9/external/rules_rust++rust+rust_analyzer_1.86.0_tools/lib/rustlib/src/library/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu" "--lockfile-path" "/tmp/rust-analyzerb7ad-0/Cargo.lock" "-Zunstable-options"`

I see the following options:

  1. Add a config and a repo rule that configures the toolchains to either use the local version of rust-analyzer or the hermetic one.
  2. Tell the IDE (emacs) to use the hermetic version of rust-analyzer.

What would be your goto solution? Do you have any other in mind?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions