Closed jaraco closed 5 months ago
Unfortunately I'm not sure and don't have my Windows machine with me right now.
Do we know if the default installation of ruff or the chocolatey installation of rust is targeting MSVC or MinGW?
From https://github.com/astral-sh/ruff/issues/11503#issuecomment-2126642384
Currently Windows builds uses
msvc
runtime.
@jaraco hopefully that helps to clarify the current build runtime for ruff
, but the same comment in #11503 also suggests that a move to target MinGW could be one way to remove the external VCRUNTIME dependency issue.
@jaraco any chance you're building inside of WSL? I'm asking because I'm surprised that it tries to build x86_64-pc-windows-gnu
instead of the msvc target.
@jaraco any chance you're building inside of WSL? I'm asking because I'm surprised that it tries to build
x86_64-pc-windows-gnu
instead of the msvc target.
Definitely not. I'm using a mostly vanilla Windows 11 install (using UTM on macOS).
I am running (and building on) Windows for ARM, so that could very well be a factor. I didn't think to mention that before.
I also was using a non-standard terminal (Hyper.js) and shell (xonsh), so that also could be a factor. I've since re-run the command using Windows Terminal and Powershell, but the build fails with the same error, so those factors are probably not a relevant concern.
@jaraco Visual Studio uses msvcrt, then you setup rust with windows-gnu
(which mainly should be used with mingw).
Use proper rustup toolchain to be compatible to Visual Studio:
> rustup toolchain install stable-x86_64-pc-windows-msvc
> rustup default stable-x86_64-pc-windows-msvc
Do we know if the default installation of ruff or the chocolatey installation of rust is targeting MSVC or MinGW?
Current binaries in Github releases are MSVC, but I verify that I can compile ruff from source via MinGW (rustup's stable-x86_64-pc-windows-gnu
target).
then you setup rust with
windows-gnu
It sounds like maybe Chocolatey's default install of rust configures for windows-gnu
. I'm slightly surprised that choice is made; I've always considered MinGW to be a fallback and for MSVC to be preferred, at least in the Python ecosystem.
Use proper rustup toolchain to be compatible to Visual Studio:
Interestingly, rustup isn't included with chocolatey's install of rust, so I can't even query the toolchains. It sounds like maybe I should abondon chocolatey and follow the install instructions on rust-lang.org.
After a boondoggle and stumbling on two bugs in httpie (https://github.com/httpie/cli/issues/1580, https://github.com/httpie/cli/issues/1581), I've managed to download rust-init.exe and uninstalled rust using chocolatey, but it unfortunately refuses to run:
~ # https static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe --download -q
~ # ./rustup-init
error: unknown proxy name: 'RUSTUP-INIT'; valid proxy names are 'rustc', 'rustdoc', 'cargo', 'rust-lldb', 'rust-gdb', 'rust-gdbgui', 'rls', 'cargo-clippy', 'clippy-driver', 'cargo-miri', 'rust-analyzer', 'rustfmt', 'cargo-fmt'
~ # https static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe --download -q
~ # ./rustup-init
error: unknown proxy name: 'RUSTUP-INIT'; valid proxy names are 'rustc', 'rustdoc', 'cargo', 'rust-lldb', 'rust-gdb', 'rust-gdbgui', 'rls', 'cargo-clippy', 'clippy-driver', 'cargo-miri', 'rust-analyzer', 'rustfmt', 'cargo-fmt'
It seems there's a bug in the installer that it can't run from my shell. When I run it from Powershell, it seems to run, so that's weird, but okay.
When I use the rustup-init installer, it does default to the default host triple of aarch64-pc-windows-msvc
, so it does seem that it's using msvc by default. I'm unsure why the chocolatey installer did something different (or what it did do).
And with that change, ruff now installs from source in my environment:
~ # pip-run git+https://github.com/jaraco/ruff@feature/honor-install-target-bin -- -m ruff --version
ruff 0.4.4
\o/
Oh, interesting, chocolatey has two different packages for rust, one with the GNU ABI and one with the MSVC ABI:
I suspect that means I could have done chocolatey install rust-ms
and had a better experience, but only because I had Visual Studio installed. No idea what would have happened if I'd not had MSVC installed.
It's kind of a shame that the GNU ABI is default, alas, and that it doesn't provide compiler support. I'll file an issue with that project notriddle/notriddle-chocolatey-packages#3.
Thanks for the help and the tips and getting me to the root of the issue.
In https://github.com/astral-sh/ruff/pull/11450#issue-2300728386, I'm attempting to build ruff from source on Windows (to validate the behavior).
When I do, it fails with the following output:
I've used Chocolatey to install rust (
choco install rust
) and installed Visual Studio and proven that other C extension modules will build.I believe the primary error message is:
Following that link fails to resolve the anchor, but following that readme into the documentation does provide some guidance with that header.
It seems that it's not
gcc
that's needed but MSVC, which is in fact installed. Apparently,cc-rs
attempts to locate it, but doesn't do a very good job, because it failed to locate it when it's installed.I suspect the issue here is with the rust ecosystem, probably cc-rs.
Since I'm not plugged into the Rust ecosystem, would someone be willing to solve the root issue on behalf of ruff users?
Do we know if the default installation of ruff or the chocolatey installation of rust is targeting MSVC or MinGW?