Reputation: 31
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
Upvotes: 3
Views: 7282
Reputation: 411
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)
Upvotes: 1
Reputation: 201
another good option is open your wsl, move to the project folder and type $ code .
or $ code YOUR_PROJECT
, then install rust-analyzer extension
Upvotes: 0
Reputation: 146
The solution is to open folder as if in WSL.
open WSL folder
and open folder with your rust project or just open new WSL window
rust-analyzer
and hit installMore info regarding the development on WSL can be found here
Upvotes: 3