fix(resolver): Include dep spec in rejected versions error

This commit is contained in:
Ed Page 2024-12-11 13:18:42 -06:00
parent 9d21153629
commit ccc00ced4d
2 changed files with 18 additions and 10 deletions

View File

@ -226,10 +226,18 @@ pub(super) fn activation_error(
Ok(c) => c,
Err(e) => return to_resolve_err(e),
};
let locked_version = dep
.version_req()
.locked_version()
.map(|v| format!(" (locked to {})", v))
.unwrap_or_default();
let _ = writeln!(
&mut msg,
"no matching versions for `{}` found",
dep.package_name()
"failed to select a version for the requirement `{} = \"{}\"`{}",
dep.package_name(),
dep.version_req(),
locked_version
);
for candidate in version_candidates {
match candidate {

View File

@ -862,7 +862,7 @@ fn relying_on_a_yank_is_bad_http() {
let _server = setup_http();
relying_on_a_yank_is_bad(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `baz` found
[ERROR] failed to select a version for the requirement `baz = "=0.0.2"`
version 0.0.2 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `bar v0.0.1`
@ -875,7 +875,7 @@ required by package `bar v0.0.1`
fn relying_on_a_yank_is_bad_git() {
relying_on_a_yank_is_bad(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `baz` found
[ERROR] failed to select a version for the requirement `baz = "=0.0.2"`
version 0.0.2 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `bar v0.0.1`
@ -922,7 +922,7 @@ fn yanks_in_lockfiles_are_ok_http() {
"#]],
str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "*"`
version 0.0.1 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.0.1 ([ROOT]/foo)`
@ -940,7 +940,7 @@ fn yanks_in_lockfiles_are_ok_git() {
"#]],
str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "*"`
version 0.0.1 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.0.1 ([ROOT]/foo)`
@ -993,7 +993,7 @@ fn yanks_in_lockfiles_are_ok_for_other_update_http() {
"#]],
str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "*"`
version 0.0.1 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.0.1 ([ROOT]/foo)`
@ -1017,7 +1017,7 @@ fn yanks_in_lockfiles_are_ok_for_other_update_git() {
"#]],
str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "*"`
version 0.0.1 is yanked
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.0.1 ([ROOT]/foo)`
@ -3228,7 +3228,7 @@ fn unknown_index_version_error() {
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "^1.0"`
version 1.0.1 requires a Cargo version that supports index version 4294967295
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.1.0 ([ROOT]/foo)`
@ -3266,7 +3266,7 @@ fn unknown_index_version_with_msrv_error() {
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] no matching versions for `bar` found
[ERROR] failed to select a version for the requirement `bar = "^1.0"`
version 1.0.1 requires cargo 1.2345
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `foo v0.1.0 ([ROOT]/foo)`