Error during downloading library for crates.io

I'm getting an error downloading dependencies from crates.io.

Cargo.toml:

[dependencies]
rand = "0.7"

Error message:

 Updating crates.io index
error: failed to get `rand` as a dependency of package `sample v0.1.0 (/home/carnot-engine/Desktop/sample)`

Caused by:
  failed to load source for dependency `rand`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  object not found - no match for id (d504bf0857fda35a79e7343e8c2f446cf9052226); class=Odb (9); code=NotFound (-3)
1 Like

That sounds weird. Try deleting your lock file?

1 Like

not working i try to create another project but same result, so it is a problem with my computer

You can delete your whole ~/.cargo/registry in case the checkout of the index is corrupted.

Problem solved. I uninstalled Rust completely and reinstalled.

    Updating crates.io index
  Downloaded rand v0.7.3
  Downloaded getrandom v0.1.14
  Downloaded libc v0.2.71
  Downloaded rand_core v0.5.1
  Downloaded rand_chacha v0.2.2
  Downloaded cfg-if v0.1.10
  Downloaded ppv-lite86 v0.2.8
   Compiling libc v0.2.71
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.8
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3

Yeah, sounds like you had some corruption in your local copy of the list of packages.

i just try to read internal files and std library of rust but i didn't edit anything or replace anything

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.