Skip to content

Conflict between native dependencies only enabled for targets we don’t care about #10099

Closed
@sebcrozet

Description

@sebcrozet

Problem

As part of the same application, I have been trying to use both wgpu 0.9 (for rendering only) and wgpu 0.11 (for compute only). However, it appears that adding both wgpu 0.9 and wgpu 0.11 dependencies yields a Cargo error:

Execution failed (exit code 101).
C:/Users/devel/.cargo/bin/cargo.exe metadata --verbose --format-version 1 --all-features
stdout :     Updating crates.io index
error: failed to select a version for `web-sys`.
    ... required by package `wgpu v0.11.0`
    ... which satisfies dependency `wgpu11 = "^0.11"` of package `wgpu_test v0.1.0 (C:\Users\devel\work\trash\wgpu-test)`
versions that meet the requirements `^0.3.53` are: 0.3.55, 0.3.54, 0.3.53

all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.50`
    ... which satisfies dependency `web-sys = "=0.3.50"` of package `wgpu v0.9.0`
    ... which satisfies dependency `wgpu = "^0.9"` of package `wgpu_test v0.1.0 (C:\Users\devel\work\trash\wgpu-test)`

failed to select a version for `web-sys` which could resolve this conflict

I understand that this is caused by the fact that we depend on two different versions of the same native library, which could cause link issues (and I guess that’s why we have a links entry on that Cargo.toml on the wasm-bindgen project). However, that web-sys dependency should be enabled only when targeting WASM:

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.76" # remember to change version in wiki as well
web-sys = { version = "0.3.53", features = [

In my case I’m only targeting native platforms and am OK having the web target fail to compile.

Is there a way not to have this dependency conflict for native dependencies that are not enabled for the platform I’m targetting?

Steps

  1. cargo new wgpu_test
  2. Copy the following Cargo.toml file:
[package]
name = "wgpu_test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
wgpu = "0.9"
wgpu11 = { package = "wgpu", version = "0.11" }
  1. cargo check will fail.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.58.0-nightly (94ca096af 2021-10-29)
release: 1.58.0
commit-hash: 94ca096afbf25f670e76e07dca754fcfe27134be
commit-date: 2021-10-29
host: x86_64-pc-windows-msvc
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:Schannel)
os: Windows 10.0.22000 (Windows 10 Pro) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions