How to blacklist a specific version of a dependency in a cargo.toml file?

Viewed 131

I have a dependency on an external library in my Cargo.toml file:

[dependencies]
foo = "0.5.6"

Unfortunately, the foo crate came out with a new release, 0.5.7, that introduces a substantial regression. There should be a new version soon™, 0.5.8 which no longer has this bug. Is there a way that I can keep cargo from pulling the bad version? I know it is possible to specify "0.5.6 or earlier", as in such:

[dependencies]
foo = "0.5.0, <0.5.7"

But is there a way to also allow for 0.5.8 to be included, whenever it gets released?

1 Answers

No, Cargo does not allow this, and using foo = "0.5.0, <0.5.7" is your best bet for now. I personally wouldn't trust that a yet to be released version is definitely going to fix your problem anyway. As soon as the new version is releases and you have tested it, you can switch to foo = "0.5.8".

You can also ask the crate author to yank version 0.5.7; Cargo won't select a yanked version, so it will use 0.5.6 as the most recent version until 0.5.8 is released. Yanking is the correct solution to deal with broken releases.

Related