27

After installing the Rust extension for VS Code, building the project fails with the following error:

Error Message Displayed by vscode

Couldn't start client Rust Language Server

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

This is in spite of the fact that rustup is installed in the system, and accessible from the VS Code terminal.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
suj1th
  • 1,781
  • 2
  • 14
  • 22

6 Answers6

43

This is an oft-reported issue in the rls-vscode repository, and I found the solution buried in some of the discussions (1, 2).

The issue seems to be with the path to the rustup executable. rustup works fine on the terminal, but VS Code cannot locate it.

Adding the following to the setting.json of the extension fixes the path for the extension.

"rust-client.rustupPath": "/home/XXX/.cargo/bin/rustup"
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
suj1th
  • 1,781
  • 2
  • 14
  • 22
  • 8
    If you are developing on remote SSH, make sure to edit your remote settings: Command Palette (Ctrl+Shift+P) -> Open remote settings. Otherwise, the "rustupPath" setting will not be available. – Isaiah Shiner Nov 26 '20 at 14:29
  • 3
    `which rustup` gives me `/snap/bin/rustup`. I modified the setting in `settings.json` accordingly, reloaded, but the problem remains. Any suggestions? – Thomas W Jan 20 '21 at 10:54
  • This solved the problem for me. Thank you – Vandad Nahavandipoor Mar 05 '22 at 10:52
3

@suj1th first cited approach fixed it for me.
Add: "rust-client.rustupPath": "$HOME/.cargo/bin/rustup" to your user settings.

Justin
  • 367
  • 2
  • 14
1

Here is a debugging/troubleshooting guide: https://github.com/rust-lang/rls/blob/master/debugging.md

My fix was to launch VSCode from the terminal with code.

remjx
  • 4,104
  • 3
  • 34
  • 32
0

On Windows:

Start > search for "Edit environment variables for account" > Edit "Path" > Add "%USERPROFILE%\.cargo\bin"

rofrol
  • 14,438
  • 7
  • 79
  • 77
0

I got this error when using nightly.
Set it back to stable, then it worked:

cargo default stable
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 19 '21 at 08:27
0

I needed to add the Windows path (without $HOME) to get it to work.

"rust-client.rustupPath": "C:/Users/myusername/.cargo/bin/rustup"