On ArchLinux based distro, vscode does not detect that Rust is installed

On an ArchLinux based distro, I have installed Visual Studio Code, I have installed the Rust extension, I installed Rust via this command sudo pacman -S rust and it installed fine, cargo works fine, I can even compile the code just fine. But vscode doesn't seem to recognise that Rustup is installed. Is there a way to fix this?

image

This is the error message I get.

The easiest/best way is to uninstall the distro package and install rustup instead. RLS and rust-analyzer depend on additional components besides the compiler, and rustup is the supported way to install those components.

I installed rustup through this command sudo pacman -S rustup but then cargo has some weird toolchain related issues?

Remove the rust package, make sure you have a rustup toolchain installed (e.g. rustup default stable), and make sure that ~/.cargo/bin is in your PATH.

If you get errors, please paste the full error message here.

1 Like

So I uninstalled rust and installed rustup.

make sure you have a rustup toolchain installed (e.g. rustup default stable ),

Is this some separate package I need to install?

image

and make sure that ~/.cargo/bin is in your PATH.

Sorry kinda noob over here, how would I do that?

Enter this command to install the stable toolchain and make it default:

rustup default stable

1 Like

Thanks that seems to work all good.

So I just wantted to ask out of curiosity why is a toolchain anyways?

“Toolchain” is a collective name for the compiler plus various associated tools and files.

1 Like

It lets you install different versions of the compiler. For example, stable, nightly, 1.44.1, or nightly-2020-06-24.

See the rustup readme for more.

Ah, that makes more sense now mate, thanks. I am surprised in Linux it is not specified by default but on Windows it is.

Rustup manages toolchains in your home dir at ~/.rustup. When you install rustup for your user, it will automatically install a default toolchain. When you install rustup globally using your package manager it can't install a default toolchain, as it doesn't know for which user it should install one.

1 Like

Arch is annoying when it comes to rust because any packages you install with pacman or an AUR helper that require rustc or cargo will not recognize the installation done with rustup. This has been true for me even though both rustc and cargo are in my PATH. What I do is just let pacman (or your AUR helper) install the distro version of rustc and then uninstall it afterwards, keeping the version from rustup. I have encountered this on 3 separate installs of Arch and Manjaro.

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.