rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.32k stars 1.61k forks source link

VS Code: `Generate launch configuration` does not respect `RUSTUP_HOME` correctly #18468

Open TheNathannator opened 2 weeks ago

TheNathannator commented 2 weeks ago

rust-analyzer version: 0.3.2162-standalone (3b3a87fe9 2024-10-27) (VS Code extension bundled)

rustc version: 1.82.0 (f6e511eec 2024-10-15)

editor or extension: VS Code, extension v0.3.2162

platform: Windows 10

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)


Using the Generate launch configuration command in VS Code fails with the following output:

Image

error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

As best as I can tell, RUSTUP_HOME is being ignored, and it instead uses the default per-user location of C:\Users\<user>\.rustup. Deleting the per-user folder and running the command again will re-generate the folder, with a default settings.toml which contains only the following:

profile = "default"
version = "12"

[overrides]

Copy-pasting the contents of the settings.toml in my RUSTUP_HOME into this one makes it work, but it then installs an independent Cargo into my user folder and re-fetches dependencies to there, which is not ideal, as I moved the directory to a secondary drive due to the limited space on my primary drive.