Compatibility policy vs crate graph resolution in Cargo #964
Labels
A-docs
Area: documentation, including docs.rs, readme, examples, etc...
C-enhancement
Category: Raise on the bar on expectations
Hello! I've noticed that in the compatibility policy section of the README you recommend a tilde dependency such as:
First off it's awesome the level of detail given here to version compatibility, hats off to that! Unfortunately though this is an over-constrained version dependency in terms of API versioning in the sense that if you've always got an up-to-date compiler you may wish to depend on
clap = "2.19.0"
instead. Normally this is ok but there's a few other bugs with Cargo at play.Right now Cargo's version resolution is pretty naive, it's just a brute-force search of the solution space, returning the first resolvable graph. This also means that it currently won't terminate until it proves there is not possible resolvable graph. This leads to situations where workspaces with multiple binaries, for example, have two different dependencies such as:
This is inherently an unresolvable crate graph in Cargo right now. Cargo requires there's only one major version of
clap
, and being in the same workspace these two crates must share a version. This is impossible in this location, though, as these version constraints cannot be met.I wonder if maybe the README could be updated with a gotcha such as this? I definitely think Cargo needs better error messages here, but in general
~
are somewhat hazardous because they can be over-constraining the dependency graph.Does that all make sense? Not sure if it's just a bit rambling, but I'm curious to hear what you think!
The text was updated successfully, but these errors were encountered: