Kristoffer
Kristoffer

Reputation: 486

Is there any way to specify that multiple versions of a dependency are valid for my library?

I am using a library that breaks depending on which other crates I am using. The way around is to downgrade a few dependencies and keep a local version of the library.

It works if I put MyLibraryDep = {version = "*"} in my Cargo.toml. Since Cargo will then fix dependencies automatically, but crates.io doesn't allow for that.

Example:

Upvotes: 2

Views: 520

Answers (1)

Sebastian Redl
Sebastian Redl

Reputation: 71969

As specified in the Cargo book, you can use inequality requirements and multiple requirements combined to form a range of valid versions.

MyLibraryDep = {version = ">=0.1.0, <=0.2.0"}

Such a requirement will also allow Cargo to choose the appropriate version and should be allowed by crates.io.

Upvotes: 5

Related Questions