Description
If you were brought here from an error message: It may be that the version of a dependency in your Cargo.lock file does not match the version of your patched dependency. You can often fix this by running cargo update -p <your package name>
. We're working on improving this error message to provide better, more detailed suggestions.
If you ran into this error message because of a different reason with a different solution, please let us know in the comments so we can address it. :)
This issue is meant to be a more long term fix than the error message updated in #4607.
From @alexcrichton:
Ideally what we'd do is upon failure do a query again for a more relaxed version constraint, seeing if you just got the wrong version. If that fails we could say that the package doesn't even exist in the source.
More details from @sunjay in the original PR (#4607)
The specific problem that I ran into occurred when I was trying to upgrade the rustfmt
submodule in the rust codebase. The rustfmt-nightly
dependency changed version numbers and this conflicted with what was in the Cargo.lock
file. After some detective work I was able to find the documentation on [patch]
which I had never read before and the following relevant paragraphs from some other documentation:
Next up we need to ensure that our lock file is updated to use this new version of uuid so our project uses the locally checked out copy instead of one from crates.io. The way [patch] works is that it'll load the dependency at ../path/to/uuid and then whenever crates.io is queried for versions of uuid it'll also return the local version.
This means that the version number of the local checkout is significant and will affect whether the patch is used. Our manifest declared uuid = "1.0" which means we'll only resolve to >= 1.0.0, < 2.0.0, and Cargo's greedy resolution algorithm also means that we'll resolve to the maximum version within that range. Typically this doesn't matter as the version of the git repository will already be greater or match the maximum version published on crates.io, but it's important to keep this in mind!
If it was not for the person who wrote those docs, I would not have known what to do here!