Cargo Error: failed to get `X` as a dependency
Asked Answered
I

3

6

I am getting this weird error:

cargo build
    Updating crates.io index
error: failed to get `anyhow` as a dependency of package `FlexDB v0.1.0 (E:\projects\FlexDB)`

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

Caused by:
  Unable to update registry `crates-io`

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

Caused by:
  missing delta bases; class=Indexer (15)

My cargo.toml file look like this:

[package]
name = "FlexDB"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1"

I don't know what to do, I did:

  1. rustup update
  2. Restart computer
Intendment answered 8/10, 2021 at 15:33 Comment(1)
Sounds like you're having internet issues ? You could try cargo clean and cargo build.Overcurious
I
12

@kornel answer did solved this error,

"It looks like your ~/.cargo/registry/index directory is corrupted. Delete it and run cargo update again."

Intendment answered 8/10, 2021 at 16:41 Comment(0)
H
0

I'm running cargo in docker container so when I got the below error, what I did was I deleted the below directory, below directory path may vary system to system, cargo will print the path along with the error

rm  -fr  /usr/local/rust/registry
Honestly answered 1/9, 2022 at 8:37 Comment(0)
R
0

If anyone else in the future has this issue whilst installing paru and comes across this - ensure you are not installing paru as the root user, you must be logged in as your user prior to installing paru.

su $your_username
cd ~
yay -S paru
Refreshment answered 12/6, 2024 at 20:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.