You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using --offline with sparse index, and attempting to resolve something that hasn't been fetched results in the following error:
error: failed to get `regex` as a dependency of package `foo v0.1.0 (/Users/eric/Temp/foo)`
Caused by:
failed to query replaced source registry `crates-io`
Caused by:
attempting to make an HTTP request, but --offline was specified
However, with non-sparse it gives the following if the index is out-of-date:
error: no matching package named `regex` found
location searched: registry `crates-io`
required by package `foo v0.1.0 (/Users/eric/Temp/foo)`
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.
I think it would be good to consider the error message in this scenario to try to help explain why --offline may fail.
If you've never fetched the sparse index, then the error message seems reasonable; and it does include the hint that the problem is caused by --offline. If the attempting to make an HTTP request, but --offline was specified error message isn't clear enough, we should change it.
However, we can probably do better when there is a local cache available, but the specific package requested isn't found. We can cause attempts to fetch a package in while in offline mode to return NotFound, which should match the git registry behavior.
Improve error for missing crate in --offline mode for sparse index
This changes sparse registries to instead return `NotFound` when a non-cached crate is requested in `--offline` mode.
The resolver can then suggest removing the `--offline` flag if resolution fails, which is a more helpful error than the one currently issued: `attempting to make an HTTP request, but --offline was specified`.
With this change, the behavior matches what is already done for git-based registries.
Closes#11276
Problem
When using
--offline
with sparse index, and attempting to resolve something that hasn't been fetched results in the following error:However, with non-sparse it gives the following if the index is out-of-date:
I think it would be good to consider the error message in this scenario to try to help explain why
--offline
may fail.Steps
cargo new foo
cd foo
echo 'regex = "*"' >> Cargo.toml
cargo generate-lockfile -Zsparse-registry --offline
Possible Solution(s)
I suspect this may be very tricky, because I think the sparse code path is failing while updating the config.json file, long before resolution starts.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: