rust-cargosea-query

Rust appears to pull in multiple versions of dependency


I have two dependencies, rustqlite and sea-query-rusqlite, in my Cargo.toml, each at the latest version:

rusqlite = "0.37"
sea-query-rusqlite = "0.7"

Running cargo check, this throws an error due to different versions of the libqlite3-sys native library:

    Updating crates.io index
error: failed to select a version for `libsqlite3-sys`.
    ... required by package `rusqlite v0.32.0`
    ... which satisfies dependency `rusqlite = "^0.32"` of package `sea-query-rusqlite v0.7.0`
    ... which satisfies dependency `sea-query-rusqlite = "^0.7"` of package `core v0.0.0 (<local_path_here>)`
versions that meet the requirements `^0.30.0` are: 0.30.1, 0.30.0

package `libsqlite3-sys` links to the native library `sqlite3`, but it conflicts with a previous package which links to `sqlite3` as well:
package `libsqlite3-sys v0.35.0`
    ... which satisfies dependency `libsqlite3-sys = "^0.35.0"` of package `rusqlite v0.37.0`
    ... which satisfies dependency `rusqlite = "^0.37"` of package `core v0.0.0 (<local_path_here>)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "sqlite3"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `libsqlite3-sys` which could resolve this conflict

What I don't understand is why cargo is trying to link dependencies for two versions of rusqlite, 0.32 and 0.37. sea-query-rusqlite depends on version ^0.32, and I depend on 0.37. Why doesn't cargo just use rusqlite 0.37 to satisfy both of these?

(Note that per the rust docs the caret character is unnecessary, e.g. 0.32 and ^0.32 are equivalent)


Solution

  • By the semver rules Cargo follows, a x.y version is compatible with a x.z version where y > z, except if x is 0. A 0.x version is not considered compatible with a 0.y version.

    https://doc.rust-lang.org/cargo/reference/semver.html