简体   繁体   中英

rust-analyzer failed to load workspace: "cargo" "--version" failed: program not found

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

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

远程开发图标

  • 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

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

Remove the rustc and cargo provide by system package manager (eg 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM