Cargo add `Command failed due to unhandled error: reference 'refs/remotes/origin/master' not found`

Viewed 741

I am getting

Command failed due to unhandled error: reference 'refs/remotes/origin/master' not found; 
class=Reference (4); code=NotFound (-3)

when trying a cargo add.

I've removed ~/.cargo/registry and reinstalled via rustup but no luck. It's thrown when I do a cargo add flexbuffers but it's not limited to just that package - it doesn't work for others e.g. serde.

1 Answers

I had to:

mv ~/.cargo/registry/index/github.com-*/.git/refs/remotes/origin/HEAD \
   ~/.cargo/registry/index/github.com-*/.git/refs/remotes/origin/master

because of this issue.

Related