Rustup components

I manage my Rust projects with the oxalica rust-overlay.

If I try to enable the rust-analyzer-preview extension, I get the following error message:

Host component `rust-analyzer-preview` doesn't support `x86_64-unknown-linux-gnu`
note: profile components: rustc cargo rust-std rust-mingw rust-docs rustfmt-preview clippy-preview
note: selected targets: x86_64-unknown-linux-gnu
note: selected extensions: rust-analyzer-preview
note: components available for x86_64-unknown-linux-gnu: cargo clippy clippy-preview llvm-tools-preview reproducible-artifacts rls rls-preview rust rust-analysis rust-docs rust-src rust-std rustc rustc-dev rustc-docs rustfmt rustfmt-preview
note: check here to see all targets and which components are available on each targets:

However, the link mentioned in the error message claims that rust-analyzer-preview has been present 'forever' (2022-01-23 -> 2022-01-29) and I am using a pinned oxalica overlay from 2022-01-22. More generally, the history listed on that page seems to be inconsistent with the reality I observe on my system.

As a separate issue, where can I find documentation for what these components do?

For example, what does the rust-analysis extension do? If enabling or disabling it does something, then I can't find what it is.

Another example: rls and rls-preview both enable the Rust Language Server. I would expect the preview version to be more recent than the plain one, but they seem to give me exactly the same version. Idem for clippy and clippy-preview.

I believe the rust-analyzer-preview component is only available for nightly rustc toolchains. You can still use stable rustc to compile your code though.

It contains the actual rust-analyzer language server that can be used by editor plugins for providing ide functionality. It is generally preferable over rls due to being much faster and having more features.

The -preview components are kept for backwards compatibility I think. -preview indicates that it is an unstable component. When stabilizing the -preview is removed from the name, but an alias with -preview is introduced.

1 Like

That was my guess. But how do you make use of it? So far, I have been installing rust-analyzer with an explicit pkgs.rust-analyzer in buildInputs. This gives me a rust-analyzer that integrates with my editor and whose version I can check on the command line with rust-analyzer --version (which gives me a frustratingly old rust-analyzer 2021-10-25). If I remove this from buildInputs, then rust-analyzer disappears from both my editor and the CLI; including the "rust-analysis" extension does not make it re-appear.

The components are described here:

In the specific case of rust-analysis, it provides metadata used by things such as rls. rust-analysis is not rust-analyzer.

As for the inconsistency between the availability of rust-analyzer-preview and what is stated on Rustup packages availability on x86_64-unknown-linux-gnu, that seems to be explained here: User Manual, where you can find the text:

rust-analyzer is available in rustup , but only in the nightly toolchain

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.