error: 'rust-analyzer' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'

2.8k views Asked by At

I have installed rust-analyzer following the instructions at https://rust-analyzer.github.io/manual.html#installation :

✔ ~> rustup component add rust-src
info: component 'rust-src' is up to date

However, I get:

✔ ~> rust-analyzer -v
error: 'rust-analyzer' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'

I have tried to install for this specific toolchain too:

✘-1 ~> rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu
info: component 'rust-src' is up to date

But I still get the same error.

I have looked for the error on the internet, and found for example discussions at https://github.com/rust-lang/rust-analyzer/issues/14776 . However, checking the executable location returns

✔ ~> which rust-analyzer
/home/jrmet/.cargo/bin/rust-analyzer

which is well within my PATH. Also, I can do:

✔ ~> /home/jrmet/.cargo/bin/rust-analyzer
error: 'rust-analyzer' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'

I have been working also with other targets:

✔ ~> rustup target list | grep installed
thumbv7em-none-eabihf (installed)
thumbv8m.main-none-eabihf (installed)
x86_64-unknown-linux-gnu (installed)

but I do not think this should play a role?

Any idea why I have this issue and how to fix it? I have a feeling I may have messed up somehow with targets and toolchains, but no idea how / where / how to fix it.

I am on Ubuntu 22.04.

1

There are 1 answers

4
Zorglub29 On BEST ANSWER

I had misunderstood the instructions on how to install rust-analyzer: what I had installed were just the dependencies, not rust-analyzer itself.

To fix this, following the instruction page:

✔ ~> rustup component add rust-analyzer
info: downloading component 'rust-analyzer'
info: installing component 'rust-analyzer'
✔ ~> rust-analyzer --version
rust-analyzer 1.73.0 (cc66ad4 2023-10-03)

My confusion stemmed from the fact that there was an executable rust-analyzer that was detected by which and was launched automatically, even though rust-analyzer was not actually installed...