Resolving workspace dependency conflicts

Hello,

I have a workspace where one of the sub crates has iced 0.12.1 as a dependency, another separate crate has bevy 0.14.0 as a dependency. Iced requires web-sys 0.3.67, bevy requires web-sys 0.3.69. Rust is unable to resolve the dependencies. I'm a rust newbie, so I'm not sure if I should expect rust to resolve these dependency issues, if changing the workspace resolver settings would be appropriate, or if this is expected and I just need to revert bevy to a version that relied on 0.3.67. I could do that but just want to make sure I understand the best/right ways to resolve these dependency conflicts.

2024-07-15T17:29:50.869456Z ERROR rust_analyzer::main_loop: FetchWorkspaceError:
rust-analyzer failed to load workspace: Failed to load the project at C:\Users\jonda\Documents\Rust\gdt\Cargo.toml: Failed to read Cargo metadata from Cargo.toml file C:\Users\jonda\Documents\Rust\gdt\Cargo.toml, Some(Version { major: 1, minor: 79, patch: 0 }): Failed to run `"C:\\Users\\jonda\\.cargo\\bin\\cargo.exe" "metadata" "--format-version" "1" "--manifest-path" "C:\\Users\\jonda\\Documents\\Rust\\gdt\\Cargo.toml" "--filter-platform" "x86_64-pc-windows-msvc"`: `cargo metadata` exited with an error: warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   C:\Users\jonda\Documents\Rust\gdt\gui\Cargo.toml
workspace: C:\Users\jonda\Documents\Rust\gdt\Cargo.toml
    Updating crates.io index
error: failed to select a version for `web-sys`.
    ... required by package `iced_winit v0.12.0`
    ... which satisfies dependency `iced_winit = "^0.12"` of package `iced v0.12.1`
    ... which satisfies dependency `iced = "^0.12.1"` of package `gdt v0.1.0 (C:\Users\jonda\Documents\Rust\gdt)`
versions that meet the requirements `=0.3.67` are: 0.3.67

all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.69`
    ... which satisfies dependency `web-sys = "^0.3.69"` of package `wgpu v0.20.1`
    ... which satisfies dependency `wgpu = "^0.20"` of package `bevy_render v0.14.0`
    ... which satisfies dependency `bevy_render = "^0.14.0"` of package `bevy_internal v0.14.0`
    ... which satisfies dependency `bevy_internal = "^0.14.0"` of package `bevy v0.14.0`
    ... which satisfies dependency `bevy = "^0.14.0"` of package `gdt v0.1.0 (C:\Users\jonda\Documents\Rust\gdt)`

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

Cargo can never build two semver compatible versions of the same dependency, regardless of your workspace setup or the resolver. If you can revert bevy to a release that doesn't require ^0.3.69 but is compatible with 0.3.67, that sounds like a good option. Updating iced to a version that doesn't have the =0.3.67 pinned version requirement on web-sys would be the best solution, but alas, there is no such version of iced available.

Ok thanks. Glad I wasn't too far off.

1 Like

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.