notify-rs/notify

Compilation error in v4

Closed this issue ยท 4 comments

Hi, could you please help me to understand the root cause of rust-lang/rustlings#1956 and rust-lang/rustlings#1958 ?

I hope that using --locked fixes this for now, but it is rather a temporary solution.

Got similar issue updating my leptos tools using

cargo install cargo-leptos leptosfmt trunk cargo-generate

cargo-leptos can't build because of errors with the notify-4.0.17 dependency.

stable-x86_64-pc-windows-gnu (default)
nightly-x86_64-pc-windows-gnu

Windows 10 with Rust 1.78.0 GNU toolchain
(MSVC toolchain is way too large for my embedded C: drive)

[..]
   Compiling notify v4.0.17
error[E0432]: unresolved import `winapi::shared::winerror`
  --> C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\notify-4.0.17\src\wi
ndows.rs:11:21
   |
11 | use winapi::shared::winerror::ERROR_OPERATION_ABORTED;
   |                     ^^^^^^^^ could not find `winerror` in `shared`

error[E0308]: mismatched types
   --> C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\notify-4.0.17\src\w
indows.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\User Name\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib/rustlib/src/rust\lib
rary\core\src\ffi\mod.rs:183:1
    |
183 | pub enum c_void {
    | ^^^^^^^^^^^^^^^
note: `winapi::ctypes::c_void` is defined in crate `winapi`
   --> C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\li
b.rs:38:5
    |
38  |     pub enum c_void {}
    |     ^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> C:\Users\User Name\.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 distinc
t types
note: `libc::c_void` is defined in crate `core`
    --> C:\Users\User Name\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib/rustlib/src/rust\li
brary\core\src\ffi\mod.rs:183:1
     |
183  | pub enum c_void {
     | ^^^^^^^^^^^^^^^
note: `winapi::ctypes::c_void` is defined in crate `winapi`
    --> C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\l
ib.rs:38:5
     |
38   |     pub enum c_void {}
     |     ^^^^^^^^^^^^^^^
note: function defined here
    --> C:\Users\User Name\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\u
m\winbase.rs:2072:12
     |
2072 |     pub fn ReadDirectoryChangesW(
     |            ^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0308, E0432.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `notify` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-leptos v0.2.17`, intermediate artifacts can be found at `C:\Users\USE
RNA~1\AppData\Local\Temp\cargo-installEqyKjD`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` t
o that path.
     Summary Successfully installed leptosfmt, trunk, cargo-generate! Failed to install cargo-leptos
(see error(s) above).
error: some crates failed to install

Hello, i have got a similar issue with
cargo install cargo-watch
can't build because of errors with the notify-4.0.17 dependency (watchexec v1.17.2)
cargo-watch Windows 10 with Rust 1.78.0 GNU toolchain

Compiling notify v4.0.17
error[E0308]: mismatched types
--> C:\Users\UserName.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\UserName.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\UserName.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\UserName.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\UserName.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\UserName.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\UserName.cargo\registry\src\index.crates.io-6f17d22bba15001f\winapi-0.3.9\src\um\winbase.rs:2072:12
|
2072 | pub fn ReadDirectoryChangesW(
| ^^^^^^^^^^^^^^^^^^^^^

Pretty sure that things in winapi from 0.3.8 to 0.3.9 changed backwards incompatible in some way - which is only exposed now. Notify v4 still uses winapi v0.3.8, but per cargo semver spec it's allowed to use 0.3.9 too. My guess is that you're now compiling with 0.3.9 and that fails. --locked prevents that.

Edit: Just found this issue from 2018, looks like there could also be missing features in winapi. Which can have two reasons: a) some dependency in your project stopped requiring a winapi feature which accidentally fixed the missing features. b) because the newer cargo feature resolver makes it possible to use the same crate with different features. So for resolver 2 a) wouldn't work anymore.

--locked
the command :
cargo install cargo-watch --locked
works for me. thank you very much @0xpr03 ๐Ÿ‘ ๐Ÿ’ฏ