Skip to content

Regression in 1.61 error message for crate not found in local registry  #10682

@jonhoo

Description

@jonhoo

Problem

The error message that's presented when a crate doesn't exist in a local registry has regressed from 1.60 to 1.61.

Steps

cargo new local-reg-regression
cd local-reg-regression
echo 'itoa = "1"' >> Cargo.toml
cargo check
mkdir .cargo
cargo local-registry -s Cargo.lock local-registry > .cargo/config.toml
$EDITOR .cargo/config.toml # make it valid TOML
sed -i 's/itoa/gxxy/' Cargo.toml
cargo check

I expected to see (and did in 1.60):

error: no matching package named `gxxy` found
location searched: registry `crates-io`
required by package `local-reg-regression v0.1.0 (/local/home/jongje/dev/tmp/local-reg-regression)`

Instead, with 1.61, I see:

error: failed to get `gxxy` as a dependency of package `local-reg-regression v0.1.0 (/local/home/jongje/dev/tmp/local-reg-regression)`

Caused by:
  failed to query replaced source registry `crates-io`

Caused by:
  failed to read `/local/home/jongje/dev/tmp/local-reg-regression/local-registry/index/gx/xy/gxxy`

Caused by:
  No such file or directory (os error 2)

Possible Solution(s)

I'm not entirely sure how this change in behavior arose. I think it may be related to #10482 and how we don't translate a ErrorKind::NotFound from read_bytes into LoadResponse::NotFound here:

Poll::Ready(Ok(LoadResponse::Data {
raw_data: paths::read_bytes(&root.join(path))?,
index_version: None,
}))

cc @arlosi

Notes

No response

Version

cargo 1.61.0 (a028ae4 2022-04-29)
release: 1.61.0
commit-hash: a028ae42fc1376571de836be702e840ca8e060c2
commit-date: 2022-04-29
host: aarch64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Amazon Linux AMI 2.0.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions