cargo install fails to update registry
Closed this issue · 13 comments
About a week ago, cargo install
has stopped working on my computer (macOS 10.12.5) with the following error:
$ cargo install --verbose racer
Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [12/-1] curl error: Could not resolve host: github.com
warning: spurious network error (1 tries remaining): [12/-1] curl error: Could not resolve host: github.com
error: failed to fetch `https://github.com/rust-lang/crates.io-index`
Caused by:
[12/-1] curl error: Could not resolve host: github.com
(Note: there's nothing spurious about this error; it has stopped working 100% of the time.)
This happens with both the current stable and nightly versions of cargo.
Pinging github.com works fine, so I don't think it's a DNS issue:
$ ping github.com
PING github.com (192.30.253.112): 56 data bytes
64 bytes from 192.30.253.112: icmp_seq=0 ttl=52 time=121.824 ms
...
I didn't notice any other network related issue on this computer.
Any ideas what the problem is?
Is there perhaps an HTTP proxy configured? I believe libcurl reads a number of environment variables and that may cause curl/cargo to behave slightly different than the bare system itself.
I don't think so. My laptop is directly connected to the wireless router provided by my ISP. I'm not aware of changing any network settings recently.
If you run env
does it looks like any proxy configuration is in there? And you don't have any .cargo/config
file that specifies proxy configuration?
I don't see any environment variables that seem related to networking except one related to SSH. Anything in particular I should look out for?
I don't have a file named config
in .cargo
. I have a file named env
in there, but it just exports .cargo/bin
to $PATH
...
Is this something like an ipv4/ipv6 problem maybe? Or maybe strace
over a cargo build
could help figure out what's going on here?
Funny that you should mention strace
, if was just trying to figure out how to run dtrace
(the macOS equivalent, if I'm not mistaken) without having to disable all security protections.. However that seems to be quite the piece of work and it's getting late over here, so I'll try this tomorrow..
How would I debug an ipv4/ipv6 problem?
Sorry I basically have no idea what's going on here, I'm just throwing out ideas. All your guesses are basically as good as mine at this point. I don't know how to debug this problem, just wondering if anything rings a bell with you.
Thanks for your help anyway..
However the problem became even stranger (TL;DR: it's now working again!): I tried adding github.com
to my etc/hosts
file and the error message changed to the following:
$ cargo install racer
Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [2/-1] failed to create locked file '/Users/my_user/.cargo/registry/index/github.com-1ecc6299db9ec823/.git/objects/pack/pack_git2_Mfidx.lock': Too many open files
warning: spurious network error (1 tries remaining): [2/-1] failed to create locked file '/Users/my_user/.cargo/registry/index/github.com-1ecc6299db9ec823/.git/objects/pack/pack_git2_TMidx.lock': Too many open files
error: failed to fetch `https://github.com/rust-lang/crates.io-index`
If I remove the entry in etc/hosts
it goes back to the error message in my opening comment.
That led me to think that maybe something got corrupt in cargo's application data and I renamed the registry
folder and retried:
$ cargo install racer
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading racer v2.0.9
Installing racer v2.0.9
error: binary `racer` already exists in destination as part of `racer v2.0.9`
Add --force to overwrite
So it seems like my cargo works again like it used to.. I'm not sure what went wrong. Do you need more information from me to investigate further or should we close this issue?
That does indeed sound odd! "Too man open files" seems suspicious but I'm not sure how we'd fix it. If it's working now though that's great! In that case yeah let's close
As a follow up, I had the same thing happen the other week. I was running MacOS High Sierra Beta, not sure if that makes a difference. I removed the registry and cargo update
was able to run just fine. Definitely seems like something got corrupt.
Just had this happen to me on mac os Sierra. wiping out the ~/.cargo/registry directory fixed it.
Same issue on 10.12.6, removing ~/.cargo/registry didn't work but a system reboot did.
It seems like the issue still persist. The last thing that I did before cargo run
stopped working was trying to step up rust for emacs which was unsuccessful. Specifically, I could not install racer crate using cargo install racer
properly. It looks like someone else was also trying to install the racer crate. Could this be a possible source of this issue?
Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [12/-17] unknown certificate check failure
warning: spurious network error (1 tries remaining): [12/-17] unknown certificate check failure
error: failed to load source for a dependency on `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:
[12/-17] unknown certificate check failure
Edit:
removing registry directory using rm -rf ~/.cargo/registry
and rebooting the system did not work either.