Cargo keeps rebuilding winapi

Hello,
on one of my computers every time I'm running a project using winapi, cargo rebuilds it. Please see a minimal example:

$ cargo new test-winapi
     Created binary (application) `test-winapi` package

$ cd test-winapi/

$ cargo add winapi
    Updating crates.io index
      Adding winapi v0.3.9 to dependencies.
             Features:
             - accctrl
			(...)
             - xinput

$ cargo run
   Compiling winapi v0.3.9
   Compiling test-winapi v0.1.0 (D:\Users\msien\source\test-winapi)
    Finished dev [unoptimized + debuginfo] target(s) in 3.61s
     Running `target\debug\test-winapi.exe`
Hello, world!

$ cargo run
   Compiling winapi v0.3.9
   Compiling test-winapi v0.1.0 (D:\Users\msien\source\test-winapi)
    Finished dev [unoptimized + debuginfo] target(s) in 0.54s
     Running `target\debug\test-winapi.exe`
Hello, world!

I found out the problem is caused by the build_script_build wich after every execution changes it's modify time so it is always newer than the binaries it builds. So they're never up to date:

$ stat ./target/debug/build/winapi-e251ea3a8c880ef1/build-script-build.exe
  File: ./target/debug/build/winapi-e251ea3a8c880ef1/build-script-build.exe
  Size: 359936          Blocks: 352        IO Block: 65536  regular file
Device: 56c4111eh/1455690014d   Inode: 844424930259360  Links: 2
Access: (0755/-rwxr-xr-x)  Uid: (197610/   msien)   Gid: (197610/ UNKNOWN)
Access: 2022-12-02 10:51:00.056375700 +0100
Modify: 2022-12-02 10:50:59.973863100 +0100
Change: 2022-12-02 10:50:59.973863100 +0100
 Birth: 2022-12-02 10:49:41.706653600 +0100

$ ./target/debug/build/winapi-e251ea3a8c880ef1/build-script-build.exe
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=WINAPI_NO_BUNDLED_LIBRARIES
cargo:rerun-if-env-changed=WINAPI_STATIC_NOBUNDLE
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotPresent', D:\Users\msien\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.9\build.rs:522:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

$ stat ./target/debug/build/winapi-e251ea3a8c880ef1/build-script-build.exe
  File: ./target/debug/build/winapi-e251ea3a8c880ef1/build-script-build.exe
  Size: 359936          Blocks: 352        IO Block: 65536  regular file
Device: 56c4111eh/1455690014d   Inode: 844424930259360  Links: 2
Access: (0755/-rwxr-xr-x)  Uid: (197610/   msien)   Gid: (197610/ UNKNOWN)
Access: 2022-12-02 11:09:50.461951100 +0100
Modify: 2022-12-02 11:09:50.405109900 +0100
Change: 2022-12-02 11:09:50.405109900 +0100
 Birth: 2022-12-02 10:49:41.7

I looked into my configurations and environmet and didn't find anything special. It just happens on 1 machine (Win 11 rigth now). Dou you guys have an idea how to fix it?

Cheers,
Marty

I seem to have the exact same problem, also on a single machine, windows 11, but on another windows 11 machine it does work. Did you ever find a solution?

Nope. Buf after the clean installation of the OS everything works fine. (I did it for a different reason) One day or another someone will find the bug :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.