Cannot install rust-analyzer-preview

I am trying to install rust-analyzer and use it with nvim. I followed the doc here, and ran rustup +nightly component add rust-analyzer-preview, but I cannot find the command when I do which rust-analyzer or which rust-analyzer-preview.

If I run rustup +nightly component add rust-analyzer-preview again, I got this:

info: component 'rust-analyzer-preview' for target 'x86_64-apple-darwin' is up to date

I think I have successfully installed it, but why can't I use it command?

There is no rustup wrapper for rust-analyzer. You will need to use rustup which rust-analyzer to get it's path instead:

$ rustup +nightly component add rust-analyzer-preview
info: downloading component 'rust-analyzer-preview'
info: installing component 'rust-analyzer-preview'
$ rustup +nightly which rust-analyzer
/home/bjorn/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer
$ /home/bjorn/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer --version
rust-analyzer 3022a2c 2021-05-27 dev

YMMV, but what works for me is pulling the binary straight from the release page on GitHub.
If you go that route, don't forget to execute chmod +x rust-analyzer.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.