rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.72k stars 2.42k forks source link

Cargo can't find adler on crates.io #11256

Closed gjf2a closed 2 years ago

gjf2a commented 2 years ago

Current Behavior

When I try to include the adler crate, the Rust compiler complains it cannot find it:

error[E0433]: failed to resolve: use of undeclared crate or module `adler`
 --> src\lib.rs:2:20
  |
2 |     let mut hash = adler::Adler32::from_checksum(value);
  |                    ^^^^^ use of undeclared crate or module `adler`

Here is my include line in Cargo.toml:

[dependencies]
adler = "1.0.2"

If I replace the above line with a link to the Github repo, it works fine:

[dependencies]
adler = { git = "https://github.com/jonas-schievink/adler" }

Expected Behavior

I expect the program to compile properly when I use the crates.io include line.

Steps To Reproduce

  1. Clone my bug-demonstration repository: https://github.com/gjf2a/adler_test
  2. Run cargo build to try to compile it.
  3. Observe the compile error message.
  4. Edit Cargo.toml to get adler from Github instead.
  5. Run cargo build to compile it.
  6. Observe that it now compiles.

Environment

OS:

Edition Windows 10 Education
Version 21H1
Installed on    ‎10/‎18/‎2021
OS build    19043.1288
Serial number   PF1C5VWB
Experience  Windows Feature Experience Pack 120.2212.3920.0

Machine:

Device name 20003LPU
Full device name    20003LPU.hendrix.local
Processor   Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz   1.99 GHz
Installed RAM   12.0 GB (11.8 GB usable)
Device ID   29A20975-2723-4644-B9A6-A9500C206F8E
Product ID  00328-10000-00001-AA962
System type 64-bit operating system, x64-based processor
Pen and touch   Pen and touch support with 10 touch points

Rust/Cargo:

PS C:\Users\ferrer\IdeaProjects\adler_test> cargo --version
cargo 1.64.0 (387270bc7 2022-09-16)
PS C:\Users\ferrer\IdeaProjects\adler_test> rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)

Anything else?

No response

Eh2406 commented 2 years ago

I was not able to reproduce. But I'm not sure what could cause this problem. Maybe something wrong with incremental compilation, in which case a cargo clean would fix it.

gjf2a commented 2 years ago

I did try cargo clean, but it had no impact whatsoever. I'm definitely happy to entertain any other suggestions that might come to mind.

gjf2a commented 2 years ago

And thank you @Eh2406 for taking a look so quickly!

Eh2406 commented 2 years ago

I wonder if something got corrupted in ~/.cargo/registry. If you dell that folder, cargo will redownload what it needs. That may help.

Turbo87 commented 2 years ago

I'm not sure what happened here either, but since https://github.com/rust-lang/crates.io-index/blob/master/ad/le/adler exists this appears to be an issue on the cargo side. unfortunately I can't transfer the issue to the cargo repo due to permissions, so I guess it might be best if you could close it here and copy over the details into https://github.com/rust-lang/cargo/issues/new?assignees=&labels=C-bug&template=bug_report.yml 🙏

Eh2406 commented 2 years ago

Transferred.

gjf2a commented 2 years ago

Deleting .cargo/registry did the trick. It now works fine! Thank you for the suggestion!