Couldn't start client Rust Language Server

9k Views Asked by At

I'm trying to figure out how to use rustc & cargo from my WSL. I use VS Code and Rust (rls) plugin and can compile my code but there is a problem with RLS:

Couldn't start client Rust Language Server

Rustup not available. Install from https://www.rustup.rs/

How i can solve this problem?

6

There are 6 best solutions below

0
On

i am running VSCode on mac, and using remote development.the remote server is ubuntu 20. i had this problem, added rust-client.rustupPath to vscode settings and killed the vscode-server on remote server to fix this problem. now it work.

0
On

Even though if I run:

which rustup
/Users/justincalleja/.cargo/bin/rustup

A simple entry of rustup in the VSCode settings for:

"Rust-client: Rustup Path Path to rustup executable. Ignored if rustup is disabled."

wasn't enough and I had to put the absolute path to the rustup binary as shown above. After doing so, I reloaded the window and was then asked to download missing components (or dependencies - the prompt is gone now I forgot). After doing this, the VSCode plugin seems to be working fine. I can format the code at least.

So it looks like it's some mismatch with VSCode's PATH and the PATH on my system. I'm not sure what it is but if you just want to get the extension to work, try using the absolute path to rustup in your Settings.

(Note: source "$HOME/.cargo/env" is added automatically to your startup files like .bashrc. First thing I tried was adding it to the startup file of zsh; the shell I'm using and to which it wasn't added. But that doesn't work either. I'm using rustc 1.49.0 (e1884a8e3 2020-12-29) ).

3
On

Set rust-client.rustupPath in VSCode settings:

{
    "rust-client.rustupPath": "~/.cargo/bin/rustup"
}

If you're using WSL on Windows then make sure you edit Rust extension WSL settings, not user/local settings.

Tutorial:

0
On

I had this problem as well with WSL and Visual Studio Code. The problem seems to stem from the fact that the Rust Language Server needs to find rustup in your path. We both probably followed the same path of using a package manager to install cargo, and therefore, the rust compiler tools. This does not include rustup which you can actually use to keep the rust toolchain up-to-date. rustup also appears to be the preferred method of installing the rust toolchain on your system.

After installing rustup with the default setup, you should see a .rustup directory in your home directory. This is where the toolchain lives. The install text all stated that it would add the toolchain to your environment path after logging out and back in, but I didn't have luck with this. I'm currently using fish instead of bash and had to update the configuration to include the toolchain at startup. Once I did that, I was able to have VSCode properly install and run the RLS.

0
On

So... I'm running Rust on Windows 10 and I experienced this same issue. My Rust version is 1.24.3, my VSCode version is 1.63.2.

  1. The first thing you need to do is add "%USERPROFILE%.cargo\bin" to your environment variables

  2. The next solution that worked for me can be found in this tutorial: Rust on Windows and Visual Studio Code

1
On

This worked for me for in a remote SSH environment with Ubuntu 20.04

  1. Edit .profile and .bashrc files in the user home directory

In .profile, comment the following line:

export PATH="$HOME/.cargo/bin:$PATH"

In both, add the following line:

[[ ":$PATH:" != *":$HOME/.cargo/bin:"* ]] && PATH="$HOME/.cargo/bin:${PATH}"
  1. Reboot.