Dependency hell: Resolving conflicting version requirements?

Problem:

  1. docopt 0.6.42 requires rustc-serialize 0.2.0, and is not going to upgrade to 0.3.x until the stdio RFC is landed;
  2. toml 0.1.18 requires rustc-serialize 0.3.0

Both docopt and toml require the user to interact directly with Decodable types, but currently cargo only allow us to use one version of rustc-serialize from crates.io (unless cargo #1311 is accepted). This means it is not possible to use the latest docopt and toml together, as the v0.2 Decodable and the v0.3 Decodable are two different traits.

Is there any good solution to this?

  • Let the user rename dependencies from crates.io (i.e. #1311), allow side-by-side usage of both versions of rustc-serialize.

  • toml 0.1.17 requires rustc-serialize 0.2.0, so the user can resolve the problem by using an older version. However, currently it is not easy to discover this dependency from crates.io.

BTW, the rustc error message when this problem happens is confusing:

src/main.rs:513:9: 513:21 error: mismatched types:
 expected `rustc-serialize::json::Json`,
    found `rustc-serialize::json::Json`
(expected enum `rustc-serialize::json::Json`,
    found a different enum `rustc-serialize::json::Json`) [E0308]
src/main.rs:513         Json::I64(v) => (v + 0x20) as u8,
                        ^~~~~~~~~~~~
...

src/main.rs:577:27: 577:53 error: the trait `rustc-serialize::json::ToJson` is not implemented for the type `rustc-serialize::json::Json` [E0277]
src/main.rs:577     let result = template.render("keylayout", &data).unwrap();
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~

...

src/main.rs:542:31: 542:47 error: the trait `rustc-serialize::serialize::Decodable` is not implemented for the type `Args` [E0277]
src/main.rs:542     let args = Args::docopt().decode::<Args>().unwrap_or_else(|e| e.exit());
                                              ^~~~~~~~~~~~~~~~
# Note: here Args has #[derive(RustcDecodable)]
2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.