Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustix depends transitively on multiple versions of windows-sys #1233

Closed
zackw opened this issue Dec 5, 2024 · 2 comments
Closed

rustix depends transitively on multiple versions of windows-sys #1233

zackw opened this issue Dec 5, 2024 · 2 comments

Comments

@zackw
Copy link

zackw commented Dec 5, 2024

The current version of the rustix crate transitively depends on multiple versions of windows-sys. This is a problem for anyone who wants to use clippy's multiple-crate-versions lint, even if their crate will never be used on Windows, as well as a problem for anyone who is using Windows.

Repro recipe:

$ mkdir test
$ cd test
$ cargo init --lib --edition 2021 --vcs none --name multiple-wsys-error
    Creating library package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cargo add rustix
    Updating crates.io index
      Adding rustix v0.38.41 to dependencies
             Features:
             + alloc
             + libc-extra-traits
             + std
             + use-libc-auxv
             34 deactivated features
    Updating crates.io index
     Locking 17 packages to latest compatible versions
      Adding linux-raw-sys v0.4.14 (latest: v0.6.5)
      Adding windows-sys v0.52.0 (latest: v0.59.0)
$ cargo clippy -- -D clippy::multiple-crate-versions
    Checking multiple-wsys-error v0.1.0 (/tmp/test)
error: multiple versions for dependency `windows-sys`: 0.52.0, 0.59.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
  = note: requested on the command line with `-D clippy::multiple-crate-versions`

error: could not compile `multiple-wsys-error` (lib) due to 1 previous error
$ cargo tree --target all
multiple-wsys-error v0.1.0 (/tmp/test)
└── rustix v0.38.41
    ├── bitflags v2.6.0
    ├── errno v0.3.10
    │   ├── libc v0.2.167
    │   └── windows-sys v0.59.0
    │       └── windows-targets v0.52.6
    │           ├── windows_aarch64_gnullvm v0.52.6
    │           ├── windows_aarch64_msvc v0.52.6
    │           ├── windows_i686_gnu v0.52.6
    │           ├── windows_i686_gnullvm v0.52.6
    │           ├── windows_i686_msvc v0.52.6
    │           ├── windows_x86_64_gnu v0.52.6
    │           ├── windows_x86_64_gnullvm v0.52.6
    │           └── windows_x86_64_msvc v0.52.6
    ├── libc v0.2.167
    ├── linux-raw-sys v0.4.14
    └── windows-sys v0.52.0
        └── windows-targets v0.52.6 (*)

You can see that rustix has a direct dependency on windows-sys 0.52, but also depends on libc 0.2.x which in turn depends on windows-sys 0.59.

Note that I, running these commands on Linux, had to use --target all to see the conflict Plain cargo tree doesn't mention errno, libc, or windows-sys at all:

$ cargo tree
multiple-wsys-error v0.1.0 (/tmp/test)
└── rustix v0.38.41
    ├── bitflags v2.6.0
    └── linux-raw-sys v0.4.14

I believe clippy is intentionally looking at the --target all dependency tree so that it reports all the conflicts at once, even if they're only relevant on systems you're not currently running on.

Please either relax your dependency on windows-sys, or restrict your dependency on libc (and possibly also errno) so that only one version of windows-sys is required.

cargo metadata dump: metadata.json

@sunfishcode
Copy link
Member

Once #1229 makes it into a release, rustix will depend on either windows-sys 0.52 or windows-sys 0.59.

@sunfishcode
Copy link
Member

This is now fixed in rustix 0.38.42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants