-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
A-dependency-resolutionArea: dependency resolution and the resolverArea: dependency resolution and the resolverA-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-semverArea: semver specifications, version matching, etc.Area: semver specifications, version matching, etc.C-bugCategory: bugCategory: bugE-easyExperience: EasyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Description
Problem
Trying to patch a stable version package (0.1.0) with prerelease version one (0.1.1-prerelease) fails with an unkind error message if there are no other matching repositories. For example,
root's Cargo.toml:
[package]
name = "cargo-mybin"
version = "0.1.0"
edition = "2021"
[dependencies]
cargo-mylib = "0.1.0"
[patch.crates-io]
cargo-mylib = { git = "https://github.com/loloicci/cargo-mylib.git" }
cargo-mylib's Cargo.toml
[package]
name = "cargo-mylib"
version = "0.1.1-prerelease"
edition = "2021"
cargo update
in this cargo-mybin fails with
$ cargo update
Updating git repository `https://github.com/loloicci/cargo-mylib.git`
Updating crates.io index
error: no matching package named `cargo-mylib` found
location searched: registry `crates-io`
required by package `cargo-mybin v0.1.0 (/.../cargo-mybin)`
This message says wrong information that no matching package was found. This is because
cargo/src/cargo/core/resolver/errors.rs
Lines 226 to 228 in 5febbe5
let all_req = semver::VersionReq::parse("*").unwrap(); | |
let mut new_dep = dep.clone(); | |
new_dep.set_version_req(all_req); |
Steps
- clone https://github.com/loloicci/cargo-mybin
- execute
cargo update
on it
Possible Solution(s)
use OptVersionReq::Any
instead of semver::VersionReq::parse("*").unwrap()
in
cargo/src/cargo/core/resolver/errors.rs
Lines 226 to 228 in 5febbe5
let all_req = semver::VersionReq::parse("*").unwrap(); | |
let mut new_dep = dep.clone(); | |
new_dep.set_version_req(all_req); |
Notes
No response
Version
$ cargo version --verbose
cargo 1.71.0-nightly (09276c703 2023-05-16)
release: 1.71.0-nightly
commit-hash: 09276c703a473ab33daaeb94917232e80eefd628
commit-date: 2023-05-16
host: x86_64-apple-darwin
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 7.64.1 (sys:0.4.61+curl-8.0.1 system ssl:(SecureTransport) LibreSSL/2.8.3)
ssl: OpenSSL 1.1.1t 7 Feb 2023
os: Mac OS 10.15.7 [64-bit]
Metadata
Metadata
Assignees
Labels
A-dependency-resolutionArea: dependency resolution and the resolverArea: dependency resolution and the resolverA-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-semverArea: semver specifications, version matching, etc.Area: semver specifications, version matching, etc.C-bugCategory: bugCategory: bugE-easyExperience: EasyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review