Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_driver.dll not found on Windows #267

Closed
BD103 opened this issue Feb 12, 2025 · 5 comments · Fixed by #281
Closed

rustc_driver.dll not found on Windows #267

BD103 opened this issue Feb 12, 2025 · 5 comments · Fixed by #281
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@BD103
Copy link
Member

BD103 commented Feb 12, 2025

I followed the installation guide on Windows, but running the linter throws an error:

$ bevy_lint
error: process didn't exit successfully: `\\?\C:\Users\USER\.cargo\bin\bevy_lint_driver.exe C:\Users\USER\.rustup\toolchains\nightly-2024-11-14-aarch64-pc-windows-msvc\bin\rustc.exe -vV` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)
Check failed: exit code: 101.

I theorize that rustup run isn't setting up the path correctly, but it still needs further investigation.

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Bug A bug in the program S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Feb 12, 2025
@BD103
Copy link
Member Author

BD103 commented Feb 12, 2025

Originally discovered on Discord.

@BD103 BD103 added this to the `bevy_lint` 0.2.0 milestone Feb 12, 2025
@BD103
Copy link
Member Author

BD103 commented Feb 12, 2025

I was able to confirm that rustup run isn't correctly configuring the path, because the following works:

# Switch to the directory that contains `rustc_driver.dll`
cd C:\Users\USER\.rustup\toolchains\nightly-2024-11-14-aarch64-pc-windows-msvc\bin
# Run the lint driver, which should print the help screen
bevy_lint_driver rustc --help

When bevy_lint_driver is run elsewhere, nothing is printed (presumably because the DLL could not be loaded).

@BD103
Copy link
Member Author

BD103 commented Feb 24, 2025

I was able to verify that rustup run doesn't configure the path (in a more straightforward way) by compiling the following program as pathfinder.exe:

fn main() {
    println!("PATH={}", std::env::var("PATH").unwrap());
}

Then, I compared the output of the following two commands:

> .\pathfinder.exe
PATH=C:\Program Files\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;
> rustup run nightly-2025-01-09 .\pathfinder.exe
PATH=C:\Program Files\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;

Diff view:

- PATH=C:\Program Files\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;
+ PATH=C:\Program Files\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;

Interestingly, the path is configured correctly when I run pathfinder.exe using cargo run:

> cargo run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `.\pathfinder.exe`
PATH=C:\Users\USER\Downloads\pathfinder\target\debug\deps;C:\Users\USER\Downloads\pathfinder\target\debug;C:\Users\USER\.rustup\toolchains\stable-aarch64-pc-windows-msvc\lib\rustlib\aarch64-pc-windows-msvc\lib;C:\Program Files\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;

@BD103
Copy link
Member Author

BD103 commented Feb 24, 2025

I found the issue! Due to 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 related to this, but it was announced before the linter was ever created. Because I don't use Windows frequently1, I never caught the issue.

We can fix this by setting RUSTUP_WINDOWS_PATH_ADD_BIN=1:

> set RUSTUP_WINDOWS_PATH_ADD_BIN=1
> rustup run nightly-2025-01-09 .\bevy_lint.exe

Footnotes

  1. Though I did use a virtual machine to debug this issue.

@BD103
Copy link
Member Author

BD103 commented Feb 24, 2025

I opened #281 to fix this issue. I also opened rust-lang/rustup#4196 to make RUSTUP_WINDOWS_PATH_ADD_BIN a little more visible in Rustup's documentation.

DaAlbrecht pushed a commit that referenced this issue Feb 24, 2025
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
> ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant