I'm rewriting the crate
cargo-prefetch (https://crates.io/crates/cargo-prefetch) which allows to download the top crates before you go offline.
Like the original
cargo prefetch, my implementation relies on calling
cargo fetch. While testing my implementation which specifies the two dependencies
semver-parser = "0.10.1" and
cargo_metadata = "0.12.1", I stumbled on this conflict:
failed to select a version for `semver-parser`. ... required by package `cargo_metadata v0.12.1` ... which is depended on by `tmp v0.0.0` versions that meet the requirements `=0.10.0` are: 0.10.0 all possible versions conflict with previously selected packages. previously selected package `semver-parser v0.10.1` ... which is depended on by `tmp v0.0.0` failed to select a version for `semver-parser` which could resolve this conflict
This has been asked on github before, but discarded: Cargo is unable to resolve dependency versions · Issue #6584 · rust-lang/cargo · GitHub
I still fail to see how this is not a bug. It simply doesn't allow me to use a version of a crate if one of my other dependencies depends on a different, SemVer-compatible version of the same crate but that version and my version don't overlap (e.g. versions <=1.0.1 and =1.0.2 are SemVer-compatible but don't overlap).
Effectively, cargo is unwilling to compile two versions of the same crate.
Are there workarounds for this? Any plans to change this behavior?