Cargo.toml crate dependency version problem

I'm using the redis-0.5.2 package which only works with url-x.y.z, x.y.z < 1.0.0. When compiling my library both url-0.5.9 and url-1.0.0. are downloaded and linking fails when redis is tried to be linked with url-1.0.0. Other packages however may depend on url-1.0.0. Two questions:

  1. Is there a way to force redis being linked (statically..?) with url-0.5.9, whilst other packages use url-1.0.0? If not:...
  2. Is there a way to stop downloading url-1.0.0 under all circumstances?

Thanks.

I'm working on pushing out a new release of Redis working with url 1.0.0

Thanks for your effort!

Do you have an idea how to continue my development based on the existing redis version in the meantime?

You can depend on the git version:

redis = { git = "https://github.com/mitsuhiko/redis-rs", branch = "updated-url" }

This will compile with url 1.0.0

Or clone the master branch, change the dependencies and use a path dependency to redis-rs

Works, thanks jer!

cc @llogiq awesome rust community

:sunny:

Just for explanation, the root problem is not you using a newer url version, but the released redis-rs using an url = "*" dependency, which means that it was fine with any version, including breaking new versions. If it did declare (e.g.) url = "0.5.0", Cargo would have downloaded both 0.5.x and 1.0.0 and everything should have worked fine: because url isn't linking to any non-Rust libraries, it'll just be compiled into the output in two different versions.

IIRC, these kinds of dependencies are now disallowed for newly published crates.

2 Likes

@birkenfeld Thanks. I tried that avenue: I corrected redis' url = "*" as you suggested and redis per se compiled fine indeed. However, my own developed library, depending on redis, caused me problems: both url versions were downloaded into my crate dependencies (...probably as you suggest...) where the linker then was trying to link redis with the newer (yet incompatible) version... With jer's suggestion I can go ahead now.

That should not happen. Did your own library depend on the correct redis version (the one you modified to have the correct dependency)?

With my current (by-me-slightly-modified) Cargo.toml in redis-0.5.2:

[dependencies]
sha1 = "*"
#url = "0.5.9"
url = "< 1.0.0"
rustc-serialize = "*"

it still wanted to link with url-1.0.0; swapping comments made no difference... Note: redis per se compiled fine, the problem started with my dependency on it....

And that's exactly what I wanted to know: how did you depend on it?

My library's Cargo.toml:

[dependencies]
url = "*"
redis = "0.5.2"

caused problems. With:

[dependencies]
url = "*"
redis = { git = "https://github.com/mitsuhiko/redis-rs", branch = "updated-url" }

it now works.

Okay. It would also work with

redis = { git = "https://github.com/mitsuhiko/redis-rs" }

as the dependency is fixed in master to url = "0.5.4". That would trigger the case I was referring to, where redis uses the 0.5.9 version, and your crate can still use 1.0.0.

Thanks!

I finally published a new version with fixed dependency versions. Still the old url, but this should built without problems now.