Skip to content

Commit 9292db9

Browse files
authored
Force rustup to add rustc_driver.dll to the PATH (#281)
Fixes #267! For more context, see [this comment](#267 (comment)): > I found the issue! Due to [rust-lang/rustup#3703](rust-lang/rustup#3703), Rustup no longer modifies the `PATH` on Windows because it prevented sub-invocations of `cargo` and `rustc` from going through their proxy. There was a [call for testing](https://internals.rust-lang.org/t/help-test-windows-behavior-between-rustup-and-cargo/20237) related to this, but it was announced before the linter was ever created. Because I don't use Windows frequently, I never caught the issue. > > We can fix this by setting `RUSTUP_WINDOWS_PATH_ADD_BIN=1`: > > ```cmd > > set RUSTUP_WINDOWS_PATH_ADD_BIN=1 > > rustup run nightly-2025-01-09 .\bevy_lint.exe > ```
1 parent 574fe10 commit 9292db9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bevy_lint/src/bin/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ fn main() -> anyhow::Result<ExitCode> {
3333
// This instructs `rustc` to call `bevy_lint_driver` instead of its default routine.
3434
// This lets us register custom lints.
3535
.env("RUSTC_WORKSPACE_WRAPPER", driver_path)
36+
// Rustup on Windows does not modify the `PATH` variable by default so a toolchain-specific
37+
// version of `cargo` or `rustc` is not accidentally run instead of Rustup's proxy version.
38+
// This isn't desired for us, however, because we need the `PATH` modified to discover and
39+
// link to `rustc_driver.dll`. Setting `RUSTUP_WINDOWS_PATH_ADD_BIN=1` forces Rustup to
40+
// modify the path. For more info, please see <https://github.com/rust-lang/rustup/pull/3703>.
41+
.env("RUSTUP_WINDOWS_PATH_ADD_BIN", "1")
3642
.status()
3743
.context("Failed to spawn `cargo check`.")?;
3844

0 commit comments

Comments
 (0)