Cargo dependencies clash

Hello,

I'm trying to use tokio 0.2.1 and tracing 0.1.10, but there is a dependency cargo doesn't know how to manage. I thought that cargo compiled rust crates with namespacing to prevent this kind of clashes. What I'm doing wrong?

error: failed to select a version for `cfg-if`.
    ... required by package `mio v0.6.20`
    ... which is depended on by `tokio v0.2.1`
    ... which is depended on by `brain v0.0.1 (/home/acasajus/Dev/cognitive/brain)`
versions that meet the requirements `= 0.1.9` are: 0.1.9

all possible versions conflict with previously selected packages.

  previously selected package `cfg-if v0.1.10`
    ... which is depended on by `tracing v0.1.10`
    ... which is depended on by `api v0.1.0 (/home/acasajus/Dev/cognitive/brain/api)`
    ... which is depended on by `brain v0.0.1 (/home/acasajus/Dev/cognitive/brain)`

failed to select a version for `cfg-if` which could resolve this conflict

Thanks in advance,

Someone messed up the cfg-if dependency in mio, so they are reverting it https://github.com/tokio-rs/mio/pull/1170

Thanks for the info. But I thought cargo namespaced the dependencies to prevent these kind of errors. Is not that the case?

Yes, but it only allows different versions of the same crate in the dependency graph if they are inherently semver incompatible. 0.1.9 and 0.1.10 are compatible, but one crate explicitly wants 0.1.9 and one crates wants >= 0.1.10, so it's a conflict. I'm not entirely sure why in that case cargo doesn't just treat them as incompatible and just compiles in both. That's why it's best to never introduce a "=0.1.10" dependency as they did here. It only causes problems. Maybe an issue on the cargo repo for handling this better could be opened, if there isn't already one.

Thanks for clarifying it :slight_smile: