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

Cargo Can't update crates.io Index #7662

Closed
Tloru opened this issue Dec 4, 2019 · 4 comments
Closed

Cargo Can't update crates.io Index #7662

Tloru opened this issue Dec 4, 2019 · 4 comments

Comments

@Tloru
Copy link

Tloru commented Dec 4, 2019

Cargo's worked for me in the past, but for some reason it stopped working today. I haven't done anything recently (that I can see) that would cause this behaviour, so I'm fairly puzzled. Here's the minimum required to encounter this error on my machine:

Start a new project, and add a dependency to cargo.toml:

# ...
[dependencies]
rand = "0.7.2"

(The package doesn't matter, the error is the same no matter what.)

upon running $ cargo run (or any command that requires crates to be fetched), I encounter the following error:

Updating crates.io index
error: failed to load source for a dependency on `rand`

Caused by:
  Unable to update registry `https:/rust-lang/crates.io-index`

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

Caused by:
  error inflating zlib stream; class=Zlib (5)

At first, I thought I might have a problem with zlib, but this doesn't seem to be the case.
I updated Rust & Cargo, but nothing changed.

(I'm running cargo 1.39.0 (1c6ec66d5 2019-09-30) on MacOS Catalina 10.15)

If you have any idea as to what's going on (is it my machine?, a cargo bug? zlib?) please don't hesitate to leave a comment 😄.

@alexcrichton
Copy link
Member

Thanks for the report!

Do you have a firewall, proxy, or any other sort of network configuration setting in effect?

@ehuss
Copy link
Contributor

ehuss commented Dec 4, 2019

You can also try setting the environment variables CARGO_HTTP_DEBUG=true and CARGO_LOG=cargo::ops::registry=debug to see if it shows anything interesting.

@Tloru
Copy link
Author

Tloru commented Dec 4, 2019

@alexcrichton - My organization does install Umbrella Roaming Client on all our laptops, however, github is not blocked, the settings have remained the same, cargo's worked without error with it in the past. I checked, and I'm able to clone the repo, curl it, or visit it online. Strange.

@ehuss - I set both of those variables and tried a few commands, but the output remained the same.

I'm starting to suspect the zlib might be the issue after all. If that's the case, is there anyway to update it, or check that it's fully functional?

@Tloru
Copy link
Author

Tloru commented Dec 5, 2019

Looking through cargo's code, I found a few potential causes for this error.

in cargo/src/cargo/sources/registry/remote.rs line 222, the code that produces the error message failed to fetch `https:/rust-lang/crates.io-index` is found. I'm pretty certain that this is the only place where this exact error message is produced. This error is thrown as a result of git::fetch failing.

git::fetch is defined in cargo/src/cargo/sources/git/utils.rson line 665. My suspicion is that cargo itself is working fine - the error message error inflating zlib stream; class=Zlib (5) is produced by a library cargo depends upon. So, what library throws this error?

Unfortunately, I wasn't able to find the exact cause of this error - I suspect it has to do with the flate2 or git2 library. While searching through cargo for the source of this error, I came across issue #5101, which suggested clearing the git cache. I ended up clearing the entirety of ~/.cargo/registry/*which fixed the issue. In the future, it might help to give a more specific error message to guide others in the right direction (e.x. something along the lines of: git fetch failed, try clearing your cargo git cache).

TL;DR: Issue was resolved by clearing the contents of the cargo registry folder (& the cargo git cache). See #5101.

@Tloru Tloru closed this as completed Dec 5, 2019
mlondschien added a commit to mlondschien/biosphere that referenced this issue Jun 14, 2022
mergify bot pushed a commit to libp2p/rust-libp2p that referenced this issue Apr 27, 2023
This PR enables debug logging on requests from cargo to the registry in semver-checks action (rust-lang/cargo#7662 (comment)). Hopefully, it will let us debug the network issue reported here: #3782 (comment)

Pull-Request: #3838.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants