skip to Main Content

I have Rust installed using WSL2 Ubuntu I have alredy ran basic commands like hello world in rust so cargo is working. I wanted to download the rust-analyzer in VSCODE but I keep getting that error message from the title: rust-analyzer failed to load workspace: "cargo" "–version" failed: program not found

I tried ensuring all paths are correct, all vesions of extension and vscode and rust are up to date. several uninstall re-installs and rustup updates. Toolchain is using stable version. I have reviewed a lot of the other post about this accross all platforms but it seems I can not find the fix. It would be very helpful to get some guidance. Thank you!st

3

Answers


  1. The solution is to open folder as if in WSL.

    • To do that you need to install this VS code extension called Remote development
    • Than go to the green symbol in the bottom right corner and then select open WSL folder and open folder with your rust project or just open new WSL window

    remote development icon

    • The last step is to go to extensions and then search for rust-analyzer and hit install

    More info regarding the development on WSL can be found here

    Login or Signup to reply.
  2. another good option is open your wsl, move to the project folder and type $ code . or $ code YOUR_PROJECT, then install rust-analyzer extension

    Login or Signup to reply.
  3. Remove the rustc and cargo provide by system package manager (e.g. apt).

    Install them from offical rustup script instead.

    [note]

    I just encounter the same problem when using flatpak version of Lapce.

    rust-analyzer failed to load workspace: "cargo" "--version" failed: No such file or directory (os error 2)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search