Clarify messaging when a new resolution needs to be performed (#14938)

We do not just "ignore" the existing lockfile here. We retain the
existing messaging for cases where we do actually throw out the
lockfile, like `--upgrade`.
This commit is contained in:
Zanie Blue 2025-07-29 20:13:30 -05:00 committed by GitHub
parent 11fe8f70f9
commit e7c8b47b7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 41 deletions

View File

@ -943,7 +943,7 @@ impl ValidatedLock {
if lock.prerelease_mode() != options.prerelease_mode {
let _ = writeln!(
printer.stderr(),
"Ignoring existing lockfile due to change in pre-release mode: `{}` vs. `{}`",
"Resolving despite existing lockfile due to change in pre-release mode: `{}` vs. `{}`",
lock.prerelease_mode().cyan(),
options.prerelease_mode.cyan()
);
@ -1015,7 +1015,7 @@ impl ValidatedLock {
// to re-use the existing fork markers.
if let Err((fork_markers_union, environments_union)) = lock.check_marker_coverage() {
warn_user!(
"Ignoring existing lockfile due to fork markers not covering the supported environments: `{}` vs `{}`",
"Resolving despite existing lockfile due to fork markers not covering the supported environments: `{}` vs `{}`",
fork_markers_union
.try_to_string()
.unwrap_or("true".to_string()),
@ -1032,7 +1032,7 @@ impl ValidatedLock {
lock.requires_python_coverage(requires_python)
{
warn_user!(
"Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `{}` vs `{}`",
"Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `{}` vs `{}`",
fork_markers_union
.try_to_string()
.unwrap_or("true".to_string()),
@ -1046,7 +1046,7 @@ impl ValidatedLock {
if let Upgrade::Packages(_) = upgrade {
// If the user specified `--upgrade-package`, then at best we can prefer some of
// the existing versions.
debug!("Ignoring existing lockfile due to `--upgrade-package`");
debug!("Resolving despite existing lockfile due to `--upgrade-package`");
return Ok(Self::Preferable(lock));
}
@ -1054,7 +1054,7 @@ impl ValidatedLock {
// the set of `resolution-markers` may no longer cover the entire supported Python range.
if lock.requires_python().range() != requires_python.range() {
debug!(
"Ignoring existing lockfile due to change in Python requirement: `{}` vs. `{}`",
"Resolving despite existing lockfile due to change in Python requirement: `{}` vs. `{}`",
lock.requires_python(),
requires_python,
);
@ -1076,7 +1076,7 @@ impl ValidatedLock {
.collect::<Vec<_>>();
if expected != actual {
debug!(
"Ignoring existing lockfile due to change in supported environments: `{:?}` vs. `{:?}`",
"Resolving despite existing lockfile due to change in supported environments: `{:?}` vs. `{:?}`",
expected, actual
);
return Ok(Self::Versions(lock));
@ -1093,7 +1093,7 @@ impl ValidatedLock {
.collect::<Vec<_>>();
if expected != actual {
debug!(
"Ignoring existing lockfile due to change in supported environments: `{:?}` vs. `{:?}`",
"Resolving despite existing lockfile due to change in supported environments: `{:?}` vs. `{:?}`",
expected, actual
);
return Ok(Self::Versions(lock));
@ -1102,7 +1102,7 @@ impl ValidatedLock {
// If the conflicting group config has changed, we have to perform a clean resolution.
if conflicts != lock.conflicts() {
debug!(
"Ignoring existing lockfile due to change in conflicting groups: `{:?}` vs. `{:?}`",
"Resolving despite existing lockfile due to change in conflicting groups: `{:?}` vs. `{:?}`",
conflicts,
lock.conflicts(),
);
@ -1149,7 +1149,7 @@ impl ValidatedLock {
}
SatisfiesResult::MismatchedMembers(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched members:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched members:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
@ -1157,11 +1157,11 @@ impl ValidatedLock {
SatisfiesResult::MismatchedVirtual(name, expected) => {
if expected {
debug!(
"Ignoring existing lockfile due to mismatched source: `{name}` (expected: `virtual`)"
"Resolving despite existing lockfile due to mismatched source: `{name}` (expected: `virtual`)"
);
} else {
debug!(
"Ignoring existing lockfile due to mismatched source: `{name}` (expected: `editable`)"
"Resolving despite existing lockfile due to mismatched source: `{name}` (expected: `editable`)"
);
}
Ok(Self::Preferable(lock))
@ -1169,11 +1169,11 @@ impl ValidatedLock {
SatisfiesResult::MismatchedDynamic(name, expected) => {
if expected {
debug!(
"Ignoring existing lockfile due to static version: `{name}` (expected a dynamic version)"
"Resolving despite existing lockfile due to static version: `{name}` (expected a dynamic version)"
);
} else {
debug!(
"Ignoring existing lockfile due to dynamic version: `{name}` (expected a static version)"
"Resolving despite existing lockfile due to dynamic version: `{name}` (expected a static version)"
);
}
Ok(Self::Preferable(lock))
@ -1181,70 +1181,70 @@ impl ValidatedLock {
SatisfiesResult::MismatchedVersion(name, expected, actual) => {
if let Some(actual) = actual {
debug!(
"Ignoring existing lockfile due to mismatched version: `{name}` (expected: `{expected}`, found: `{actual}`)"
"Resolving despite existing lockfile due to mismatched version: `{name}` (expected: `{expected}`, found: `{actual}`)"
);
} else {
debug!(
"Ignoring existing lockfile due to mismatched version: `{name}` (expected: `{expected}`)"
"Resolving despite existing lockfile due to mismatched version: `{name}` (expected: `{expected}`)"
);
}
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedRequirements(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched requirements:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched requirements:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedConstraints(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched constraints:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched constraints:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedOverrides(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched overrides:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched overrides:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedBuildConstraints(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched build constraints:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched build constraints:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedDependencyGroups(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched dependency groups:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched dependency groups:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MismatchedStaticMetadata(expected, actual) => {
debug!(
"Ignoring existing lockfile due to mismatched static metadata:\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched static metadata:\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MissingRoot(name) => {
debug!("Ignoring existing lockfile due to missing root package: `{name}`");
debug!("Resolving despite existing lockfile due to missing root package: `{name}`");
Ok(Self::Preferable(lock))
}
SatisfiesResult::MissingRemoteIndex(name, version, index) => {
debug!(
"Ignoring existing lockfile due to missing remote index: `{name}` `{version}` from `{index}`"
"Resolving despite existing lockfile due to missing remote index: `{name}` `{version}` from `{index}`"
);
Ok(Self::Preferable(lock))
}
SatisfiesResult::MissingLocalIndex(name, version, index) => {
debug!(
"Ignoring existing lockfile due to missing local index: `{name}` `{version}` from `{}`",
"Resolving despite existing lockfile due to missing local index: `{name}` `{version}` from `{}`",
index.display()
);
Ok(Self::Preferable(lock))
@ -1252,12 +1252,12 @@ impl ValidatedLock {
SatisfiesResult::MismatchedPackageRequirements(name, version, expected, actual) => {
if let Some(version) = version {
debug!(
"Ignoring existing lockfile due to mismatched requirements for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched requirements for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
} else {
debug!(
"Ignoring existing lockfile due to mismatched requirements for: `{name}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched requirements for: `{name}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
}
@ -1266,12 +1266,12 @@ impl ValidatedLock {
SatisfiesResult::MismatchedPackageDependencyGroups(name, version, expected, actual) => {
if let Some(version) = version {
debug!(
"Ignoring existing lockfile due to mismatched dependency groups for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched dependency groups for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
} else {
debug!(
"Ignoring existing lockfile due to mismatched dependency groups for: `{name}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched dependency groups for: `{name}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
}
@ -1280,19 +1280,19 @@ impl ValidatedLock {
SatisfiesResult::MismatchedPackageProvidesExtra(name, version, expected, actual) => {
if let Some(version) = version {
debug!(
"Ignoring existing lockfile due to mismatched extras for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched extras for: `{name}=={version}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
} else {
debug!(
"Ignoring existing lockfile due to mismatched extras for: `{name}`\n Requested: {:?}\n Existing: {:?}",
"Resolving despite existing lockfile due to mismatched extras for: `{name}`\n Requested: {:?}\n Existing: {:?}",
expected, actual
);
}
Ok(Self::Preferable(lock))
}
SatisfiesResult::MissingVersion(name) => {
debug!("Ignoring existing lockfile due to missing version: `{name}`");
debug!("Resolving despite existing lockfile due to missing version: `{name}`");
Ok(Self::Preferable(lock))
}
}

View File

@ -4804,7 +4804,7 @@ fn lock_requires_python_wheels() -> Result<()> {
----- stderr -----
Using CPython 3.11.[X] interpreter at: [PYTHON-3.11]
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version == '3.12.*'` vs `python_full_version == '3.11.*'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version == '3.12.*'` vs `python_full_version == '3.11.*'`
Resolved 2 packages in [TIME]
");
@ -16338,7 +16338,7 @@ fn lock_explicit_default_index() -> Result<()> {
DEBUG Using request timeout of [TIME]
DEBUG Found static `pyproject.toml` for: project @ file://[TEMP_DIR]/
DEBUG No workspace root found, using project root
DEBUG Ignoring existing lockfile due to mismatched requirements for: `project==0.1.0`
DEBUG Resolving despite existing lockfile due to mismatched requirements for: `project==0.1.0`
Requested: {Requirement { name: PackageName("anyio"), extras: [], groups: [], marker: true, source: Registry { specifier: VersionSpecifiers([]), index: None, conflict: None }, origin: None }}
Existing: {Requirement { name: PackageName("iniconfig"), extras: [], groups: [], marker: true, source: Registry { specifier: VersionSpecifiers([VersionSpecifier { operator: Equal, version: "2.0.0" }]), index: Some(IndexMetadata { url: Url(VerbatimUrl { url: DisplaySafeUrl { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("test.pypi.org")), port: None, path: "/simple", query: None, fragment: None }, given: None }), format: Simple }), conflict: None }, origin: None }}
DEBUG Solving with installed Python version: 3.12.[X]
@ -28365,16 +28365,16 @@ fn lock_invalid_fork_markers() -> Result<()> {
"#,
)?;
uv_snapshot!(context.filters(), context.lock(), @r###"
uv_snapshot!(context.filters(), context.lock(), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: Ignoring existing lockfile due to fork markers not covering the supported environments: `(python_full_version >= '3.8' and python_full_version < '3.10') or (python_full_version >= '3.8' and platform_python_implementation == 'CPython')` vs `python_full_version >= '3.8'`
warning: Resolving despite existing lockfile due to fork markers not covering the supported environments: `(python_full_version >= '3.8' and python_full_version < '3.10') or (python_full_version >= '3.8' and platform_python_implementation == 'CPython')` vs `python_full_version >= '3.8'`
Resolved 2 packages in [TIME]
Updated idna v3.10 -> v3.6
"###);
");
// Check that the lockfile got updated and we don't show the warning anymore.
uv_snapshot!(context.filters(), context.lock(), @r###"
@ -28671,7 +28671,7 @@ fn lock_requires_python_empty_lock_file() -> Result<()> {
----- stderr -----
Using CPython 3.13.2 interpreter at: [PYTHON-3.13.2]
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version == '3.13.0'` vs `python_full_version == '3.13.2'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version == '3.13.0'` vs `python_full_version == '3.13.2'`
Resolved 3 packages in [TIME]
");

View File

@ -8830,7 +8830,7 @@ fn sync_dry_run() -> Result<()> {
----- stderr -----
Using CPython 3.9.[X] interpreter at: [PYTHON-3.9]
Would replace project environment at: .venv
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.12'` vs `python_full_version == '3.9.*'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.12'` vs `python_full_version == '3.9.*'`
Resolved 2 packages in [TIME]
Would update lockfile at: uv.lock
Would install 1 package
@ -8847,7 +8847,7 @@ fn sync_dry_run() -> Result<()> {
Using CPython 3.9.[X] interpreter at: [PYTHON-3.9]
Removed virtual environment at: .venv
Creating virtual environment at: .venv
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.12'` vs `python_full_version == '3.9.*'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.12'` vs `python_full_version == '3.9.*'`
Resolved 2 packages in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
@ -9338,7 +9338,7 @@ fn sync_locked_script() -> Result<()> {
----- stderr -----
Updating script environment at: [CACHE_DIR]/environments-v2/script-[HASH]
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.11'` vs `python_full_version >= '3.8' and python_full_version < '3.11'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.11'` vs `python_full_version >= '3.8' and python_full_version < '3.11'`
Resolved 6 packages in [TIME]
The lockfile at `uv.lock` needs to be updated, but `--locked` was provided. To update the lockfile, run `uv lock`.
");
@ -9350,7 +9350,7 @@ fn sync_locked_script() -> Result<()> {
----- stderr -----
Using script environment at: [CACHE_DIR]/environments-v2/script-[HASH]
warning: Ignoring existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.11'` vs `python_full_version >= '3.8' and python_full_version < '3.11'`
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.11'` vs `python_full_version >= '3.8' and python_full_version < '3.11'`
Resolved 6 packages in [TIME]
Prepared 2 packages in [TIME]
Installed 6 packages in [TIME]