`cargo install` failed on Windows 11
tk-nguyen opened this issue ยท 5 comments
Hello, I'm trying to install cargo-watch
on Windows 11 with cargo install
, but it ran into an issue while compiling:
$ cargo install cargo-watch
Updating crates.io index
Installing cargo-watch v8.5.2
Updating crates.io index
Compiling proc-macro2 v1.0.81
Compiling unicode-ident v1.0.12
<... lots of lines ...>
Compiling which v4.4.2
Compiling darling_core v0.12.4
Compiling notify v4.0.17
Compiling command-group v1.0.8
error[E0308]: mismatched types
--> C:\Users\thainguyen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\notify-4.0.17\src\windows.rs:276:29
|
276 | overlapped.hEvent = request_p;
| ----------------- ^^^^^^^^^ expected `winapi::ctypes::c_void`, found `libc::c_void`
| |
| expected due to the type of this binding
|
= note: `libc::c_void` and `winapi::ctypes::c_void` have similar names, but are actually distinct types
note: `libc::c_void` is defined in crate `core`
--> C:\Users\thainguyen\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ffi\mod.rs:183:1
|
183 | pub enum c_void {
| ^^^^^^^^^^^^^^^
note: `winapi::ctypes::c_void` is defined in crate `winapi`
--> C:\Users\thainguyen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\lib.rs:38:5
|
38 | pub enum c_void {}
| ^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> C:\Users\thainguyen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\notify-4.0.17\src\windows.rs:282:13
|
280 | let ret = winbase::ReadDirectoryChangesW(
| ------------------------------ arguments to this function are incorrect
281 | handle,
282 | req_buf,
| ^^^^^^^ expected `winapi::ctypes::c_void`, found `libc::c_void`
|
= note: `libc::c_void` and `winapi::ctypes::c_void` have similar names, but are actually distinct types
note: `libc::c_void` is defined in crate `core`
--> C:\Users\thainguyen\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ffi\mod.rs:183:1
|
183 | pub enum c_void {
| ^^^^^^^^^^^^^^^
note: `winapi::ctypes::c_void` is defined in crate `winapi`
--> C:\Users\thainguyen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\lib.rs:38:5
|
38 | pub enum c_void {}
| ^^^^^^^^^^^^^^^
note: function defined here
--> C:\Users\thainguyen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winbase.rs:2072:12
|
2072 | pub fn ReadDirectoryChangesW(
| ^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `notify` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-watch v8.5.2`, intermediate artifacts can be found at `C:\Users\THAING~1\AppData\Local\Temp\cargo-installzpBRP9`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Here's my current rust
and cargo
version:
$ cargo --version --verbose
cargo 1.78.0 (54d8815d0 2024-03-26)
release: 1.78.0
commit-hash: 54d8815d04fa3816edc207bbc4dd36bf18014dbc
commit-date: 2024-03-26
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.22631 (Windows 11 Education) [64-bit]
$ rustc --version --verbose
rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-pc-windows-msvc
release: 1.78.0
LLVM version: 18.1.2
Try with --locked
? Or use a binary release
Try with
--locked
? Or use a binary release
cargo install --locked
seems to work fine. Thanks!
$ cargo install --locked cargo-watch
Updating crates.io index
Installing cargo-watch v8.5.2
Updating crates.io index
warning: package `iana-time-zone v0.1.59` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
Updating crates.io index
Downloaded autocfg v1.1.0
Downloaded bitflags v2.4.1
Downloaded cargo-platform v0.1.6
Downloaded itoa v1.0.10
<... lots of lines ...>
Compiling cargo-watch v8.5.2
Finished `release` profile [optimized] target(s) in 1m 00s
Installing C:\Users\thainguyen\.cargo\bin\cargo-watch.exe
Installed package `cargo-watch v8.5.2` (executable `cargo-watch.exe`)
Hello, for what its worth: I encountered the same issue and error messages using the gnu-windows toolchain on windows 11. Using cargo install --locked
seemed to work as well.
cargo install cargo-watch
was working previously on my setup from about 2 months ago when I was switching from msvc to gnu windows toolchains..
Just encountered this issue as well, maybe it would be a good idea to put a note to the README about trying the --locked
version in case installation fails.