Skip to content

cargo 0.73 build broken on windows #12562

@est31

Description

@est31

I updated cargo to 0.73 from crates.io in cargo-udeps (commit) and got the following build failure on ci:

 error[E0432]: unresolved import `windows_sys::Win32::Storage::FileSystem::LockFileEx`
   --> C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cargo-0.73.0\src/cargo\util\flock.rs:443:9
    |
443 |         LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY,
    |         ^^^^^^^^^^
    |         |
    |         no `LockFileEx` in `Windows::Win32::Storage::FileSystem`
    |         help: a similar name exists in the module: `LockFile`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `cargo` (lib) due to previous error

If you look at the rustdoc for LockFileEx, it writes:

Required features: "Win32_Storage_FileSystem", "Win32_Foundation", "Win32_System_IO"

Compare this with the Cargo.toml of 0.73:

cargo/Cargo.toml

Lines 180 to 188 in 103a7ff

[target.'cfg(windows)'.dependencies.windows-sys]
workspace = true
features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
"Win32_System_Console",
"Win32_System_Threading",
"Win32_System_JobObjects",
]

The former two are found while Win32_System_IO isn't present. I suppose this is the cause for the failure: in the cargo repo this works fine because of dependency unification and another crate in the DAG enabling the Win32_System_IO features. But if you use cargo from crates.io, then it is not enabled, which is what I ran into.

The fix is simple, just add Win32_System_IO to the list. Ideally this would also be published in a new release.

I have worked around the issue by making cargo-udeps depend on windows-sys and enabling the feature (commit).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-apiArea: cargo-the-library API and internal code issuesO-windowsOS: WindowsP-highPriority: HighS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions