VSCode rust-analyzer "Failed to load workspaces" (os error 5)

I use VSCode under Windows 10 and tried to use the rust-analyzer plugin (the other rust plugin is not installed).
When I open the editor, I see that the rust-analyzer plugin "Failed to load workspaces".
The full output is:

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: "C:\\Users\\linus\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\bin" "--version" failed: Access denied (os error 5)

The output of "rustup show" is:

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\linus\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.67.1 (d5a82bbd2 2023-02-07)

Running VSCode as admin did not solve the issue.

Do you have the CARGO env vars set? And if so to what value?

1 Like

Yes, I had a environment variable named cargo linking to C:\\Users\\linus\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\bin so that I could use rustc everywhere.
Now that I have deleted this variable, everything works fine.
Thank you for your help.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.