Cargo - Failed to select a version for <crate>

I'm trying to compile my project after going back and updating some libraries. I'm having an issue where I am using two crates that are using two different versions of the 'log' crate.

Is it possible to force cargo to use a certain version of a crate? Or allow cargo to use one version in one place, another version in another place?


When built with "cargo build":
error: failed to select a version for log.
... required by package tokio-uds v0.2.1
... which is depended on by tokio v0.1.22
... which is depended on by fractal-api v0.9.39 (/home/leo/IdeaProjects/proxyserver/api-rs)
versions that meet the requirements ^0.4.2 are: 0.4.8, 0.4.7, 0.4.6, 0.4.5, 0.4.4, 0.4.3, 0.4.2

all possible versions conflict with previously selected packages.

previously selected package log v0.4.1
... which is depended on by h2 v0.1.26
... which is depended on by hyper v0.12.35
... which is depended on by fractal-api v0.9.39 (/home/leo/IdeaProjects/proxyserver/api-rs)

failed to select a version for log which could resolve this conflict


When built with "cargo tree | grep tokio":
error: failed to select a version for log.
... required by package tokio-uds v0.2.1
... which is depended on by tokio v0.1.22
... which is depended on by fractal-api v0.9.39 (/home/leo/IdeaProjects/proxyserver/api-rs)
versions that meet the requirements ^0.4.2 are: 0.4.8, 0.4.7, 0.4.6, 0.4.5, 0.4.4, 0.4.3, 0.4.2

all possible versions conflict with previously selected packages.

previously selected package log v0.4.1
... which is depended on by tokio-threadpool v0.1.15
... which is depended on by tokio v0.1.22
... which is depended on by fractal-api v0.9.39 (/home/leo/IdeaProjects/proxyserver/api-rs)

failed to select a version for log which could resolve this conflict

In case any one else comes across this looking for an answer:
You can add the version of the crate you want Rust to use in Cargo.toml then Rust will use that everywhere.

Still annoying that Rust can't simply use both when crates you import use different versions of the same crate... This fixes this issue in my case because both crates had a version of the same crate that worked, but not in every case.

1 Like