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.
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:
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...