From 4123762e5abb1fdfc2d40df65399c7e1a9259425 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 16 Aug 2024 15:21:20 -0500 Subject: [PATCH] Improve resolver error messages when `--offline` is used --- crates/uv-resolver/src/pubgrub/report.rs | 2 +- crates/uv-resolver/src/resolver/availability.rs | 4 +--- crates/uv/tests/cache_prune.rs | 4 ++-- crates/uv/tests/lock.rs | 2 +- crates/uv/tests/pip_compile.rs | 6 +++--- crates/uv/tests/pip_sync.rs | 4 ++-- crates/uv/tests/workspace.rs | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/crates/uv-resolver/src/pubgrub/report.rs b/crates/uv-resolver/src/pubgrub/report.rs index 4aafa5ba5b6d..729d943d5bd7 100644 --- a/crates/uv-resolver/src/pubgrub/report.rs +++ b/crates/uv-resolver/src/pubgrub/report.rs @@ -827,7 +827,7 @@ impl std::fmt::Display for PubGrubHint { Self::Offline => { write!( f, - "{}{} Packages were unavailable because the network was disabled", + "{}{} Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache.", "hint".bold().cyan(), ":".bold(), ) diff --git a/crates/uv-resolver/src/resolver/availability.rs b/crates/uv-resolver/src/resolver/availability.rs index 1b01cb25f5da..4ae7ebc5e4c5 100644 --- a/crates/uv-resolver/src/resolver/availability.rs +++ b/crates/uv-resolver/src/resolver/availability.rs @@ -52,9 +52,7 @@ impl Display for UnavailableVersion { UnavailableVersion::InvalidMetadata => f.write_str("has invalid metadata"), UnavailableVersion::InconsistentMetadata => f.write_str("has inconsistent metadata"), UnavailableVersion::InvalidStructure => f.write_str("has an invalid package format"), - UnavailableVersion::Offline => f.write_str( - "network connectivity is disabled, but the metadata wasn't found in the cache", - ), + UnavailableVersion::Offline => f.write_str("needs to be downloaded from a registry"), } } } diff --git a/crates/uv/tests/cache_prune.rs b/crates/uv/tests/cache_prune.rs index c53cfde87b23..7c1bfd39e4a5 100644 --- a/crates/uv/tests/cache_prune.rs +++ b/crates/uv/tests/cache_prune.rs @@ -248,12 +248,12 @@ fn prune_unzipped() -> Result<()> { iniconfig==1.1.0 iniconfig==1.1.1 iniconfig==2.0.0 - network connectivity is disabled, but the metadata wasn't found in the cache, we can conclude that iniconfig<1.0.0 cannot be used. + needs to be downloaded from a registry, we can conclude that iniconfig<1.0.0 cannot be used. And because you require iniconfig, we can conclude that your requirements are unsatisfiable. hint: Pre-releases are available for iniconfig in the requested range (e.g., 0.2.dev0), but pre-releases weren't enabled (try: `--prerelease=allow`) - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "###); Ok(()) diff --git a/crates/uv/tests/lock.rs b/crates/uv/tests/lock.rs index cb6448ddce10..eb3d487788bf 100644 --- a/crates/uv/tests/lock.rs +++ b/crates/uv/tests/lock.rs @@ -8602,7 +8602,7 @@ fn lock_add_member() -> Result<()> { ╰─▶ Because anyio was not found in the cache and leaf depends on anyio>3, we can conclude that leaf's requirements are unsatisfiable. And because your workspace requires leaf, we can conclude that your workspace's requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "###); // Re-run without `--locked`. diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 99392ee61484..260e0d16d79e 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -5513,7 +5513,7 @@ fn offline_registry() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because black was not found in the cache and you require black==23.10.1, we can conclude that your requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### ); @@ -5644,7 +5644,7 @@ fn offline_find_links() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because tqdm was not found in the cache and you require tqdm, we can conclude that your requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### ); @@ -5663,7 +5663,7 @@ fn offline_find_links() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because tqdm was not found in the cache and you require tqdm, we can conclude that your requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### ); diff --git a/crates/uv/tests/pip_sync.rs b/crates/uv/tests/pip_sync.rs index 3f5871f48829..605500ab2866 100644 --- a/crates/uv/tests/pip_sync.rs +++ b/crates/uv/tests/pip_sync.rs @@ -2789,7 +2789,7 @@ fn find_links_offline_no_match() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because numpy was not found in the cache and you require numpy, we can conclude that your requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### ); @@ -2916,7 +2916,7 @@ fn offline() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because black was not found in the cache and you require black==23.10.1, we can conclude that your requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### ); diff --git a/crates/uv/tests/workspace.rs b/crates/uv/tests/workspace.rs index 76acda86cf95..73423d4bbf4e 100644 --- a/crates/uv/tests/workspace.rs +++ b/crates/uv/tests/workspace.rs @@ -1011,7 +1011,7 @@ fn workspace_inherit_sources() -> Result<()> { ╰─▶ Because library was not found in the cache and leaf depends on library, we can conclude that leaf's requirements are unsatisfiable. And because your workspace requires leaf, we can conclude that your workspace's requirements are unsatisfiable. - hint: Packages were unavailable because the network was disabled + hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. "### );