I get the follow error when running cargo install, upgrade and build commands
cargo install -v racer
Updating registry https://github.com/rust-lang/crates.io-index
failed to fetch https://github.com/rust-lang/crates.io-index
Caused by:
[4/-1] Corrupted loose reference file: HEAD
Interesting! Maybe a previous operation corrupted the index by accident? You should be able to fix this by rm -rf $CARGO_HOME/registry/index, but that shouldn't be necessary in theory.
Hmm I deleted the index at that does seem to have fixed it, I wonder if its corrupted in the latest windows GNU distribution of Rust or it could just be my system.
I ran into this error today. registry/src was apparently also corrupted (several crates had empty Cargo.tomls). Removing them both convinced cargo build to start building, but IMO cargo should know how to recover from this error, or at least continue without updating the registry as a fallback.
@durka hm so the corruption you ran into wasn't the git index, it was the unpacked tarballs?
@alexcrichton well the index was definitely corrupted, and I had to delete it to get past the error shown here. But then it started complaining that it "couldn't get packages from source" because the Cargo.toml was corrupted, and when I checked the Cargo.toml it was complaining about, it sure was empty. I don't know if it was a crate that was already in the cache or a new one that didn't download well. After deleting the src directory the build completed.
Interesting! I'll take another look at the index updating code to ensure it handles corruption, and we can just keep an eye out for src corruption as well (as it in theory is written in a way that it doesn't happen)
happened to me today as well. no warning
Suddenly happened to me on Windows 7. I deleted _registry/index_ folder and then cargo build started working again! Relief!
Most helpful comment
Interesting! Maybe a previous operation corrupted the index by accident? You should be able to fix this by
rm -rf $CARGO_HOME/registry/index, but that shouldn't be necessary in theory.