Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unusable due to having an invalid HEAD reference" when running cargo upgrade #15088

Closed
cdstanford opened this issue Jan 22, 2025 · 2 comments
Closed
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@cdstanford
Copy link

cdstanford commented Jan 22, 2025

Problem

Hi, I am getting this error when running cargo upgrade:

The repo at path /Users/caleb/.cargo/registry/index/github.com-1ecc6299db9ec823 is unusable due to having an invalid HEAD reference: reference 'refs/heads/master' not found; class=Reference (4); code=NotFound (-3)

I tried running cargo clean and rustup upgrade but the problem persists. Any idea what might be going on and how to fix?

This is a similar error to this issue except that I am not trying to use a different registry. It appears to occur on any repository, including when creating one with cargo init:

(base) caleb:git $ mkdir test-repo
(base) caleb:git $ cd test-repo
(base) caleb:test-repo $ cargo init
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
(base) caleb:test-repo $ cargo upgrade
Error: The repo at path /Users/caleb/.cargo/registry/index/github.com-1ecc6299db9ec823 is unusable due to having an invalid HEAD reference: reference 'refs/heads/master' not found; class=Reference (4); code=NotFound (-3)

Thanks!

Steps

I don't have steps to reproduce as this may occur only on my setup.

Possible Solution(s)

I tried running cargo clean and rustup upgrade but the problem persists.

I have not tried doing a fresh uninstall/reinstall of rustup and Rust, but I can try that if this appears to be something totally broken with my setup.

Notes

No response

Version

$ cargo version --verbose
cargo 1.84.0 (66221abde 2024-11-19)
release: 1.84.0
commit-hash: 66221abdeca2002d318fde6efff516aab091df0e
commit-date: 2024-11-19
host: aarch64-apple-darwin
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 15.2.0 [64-bit]
@cdstanford cdstanford added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jan 22, 2025
@weihanglo
Copy link
Member

Note that cargo upgrade is a third-party plugin offered by https://github.com/killercup/cargo-edit. Have you filed an issue there?

Anyway, it might be git index was corrupted during download. You could remove /Users/caleb/.cargo/registry/index/github.com-1ecc6299db9ec823 directory and try again.
Also, [email protected] uses sparse index registry by default. You might have been using the old version of cargo-edit.

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Jan 22, 2025
@cdstanford
Copy link
Author

Thanks! Forgot that cargo upgrade is third party - cargo uninstall cargo-edit followed by cargo install cargo-edit seems to have solved the problem. I didn't raise at https://github.com/killercup/cargo-edit but I will do so if the problem comes back or if others have this issue later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants