Skip to content

Commit

Permalink
Improve resolver error messages when --offline is used
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Aug 16, 2024
1 parent 05cceee commit 4123762
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/uv-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down
4 changes: 1 addition & 3 deletions crates/uv-resolver/src/resolver/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"###
);

Expand Down Expand Up @@ -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.
"###
);

Expand All @@ -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.
"###
);

Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"###
);

Expand Down Expand Up @@ -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.
"###
);

Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"###
);

Expand Down

0 comments on commit 4123762

Please sign in to comment.