2

https://www.rust-lang.org/tools/install states that one can install Rust using WSL, which works fine. However, it seems like the rust-analyzer addon for VSCode can only leverage the rust installation of the host system by default as it cannot find the cargo installation during startup and fails with this message:

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: "cargo" "--version" failed: program not found

Is there a way to configure rust-analyzer to use my WSL Rust installation?

Another option would of course be to use Dev Containers but that would be pretty cumbersome for the particular project I am working on.

rioV8
  • 24,506
  • 3
  • 32
  • 49
lema
  • 344
  • 7
  • 15
  • Can you use `cargo` in your WSL shell normally, after you install `Rust` toolchain in WSL according to official guide? It looks like vscode can not locate the `cargo` command, which may be the reason of the path of `cargo` not being included in the `PATH` environment variable. – rustyhu Mar 14 '23 at 11:34
  • Yes, I can. In WSL everything works fine. As I understand it, binaries installed in WSL cannot be used in the host system, though, or am I wrong? If I could put the WSL Rust installation to the Windows PATH this would solve the problem but I don't think this is possible. – lema Mar 14 '23 at 12:15
  • 1
    you need to install the wsl remoting extension in vscode and then open the project through that. – the8472 Mar 14 '23 at 16:37
  • After some tinkering, the WSL container approach is the only approach that works somewhat. Unfortunately, there are still problems because of the access rights to the project folders in the WSL container. Maybe I can find a workaround for that. Thanks! – lema Mar 15 '23 at 18:53

0 Answers0