Cargo: [Bug] Spurious network error: failed to read data: The server returned an invalid or unrecognized response

Created on 17 Jul 2020  路  12Comments  路  Source: rust-lang/cargo

Problem
I am trying to update crates.io so I can install regex as a dependency.
However, each time I run cargo build I get the following error.

    Updating crates.io index
warning: spurious network error (2 tries remaining): failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)
warning: spurious network error (1 tries remaining): failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)
error: failed 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:
  failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)

Steps

  1. Install rust
  2. Create a project with a dependancy
  3. Run cargo build

Notes

I have tried it on my main computer and did a fresh install on my Linux computer and neither worked (both had same error).
Also, I ran curl for https://github.com/rust-lang/crates.io-index and it resolved without error.

Cargo version: cargo 1.44.1 (88ba85757 2020-06-11)
Rustc version: rustc 1.44.1 (c7087fe00 2020-06-17)
OS: Windows 10 (latest)
Network: Good connection

C-bug

All 12 comments

Can you try enabling HTTP debugging and gist the logs?

Hm that's the same output as before, to confirm @TheOtterlord did you enable the CARGO_LOG environment variable as well as the http.debug configuration option?

Ah, I did not do the CARGO_LOG. Sorry, I'm new to this. Where do I place/use CARGO_LOG?

It depends on the shell you're using for Windows, but I think set CARGO_LOG=cargo::ops::registry should work if you're using cmd.exe

I've updated my gist but I think the command log deleted the first few lines as I could not find the part where I called the command.

Edit: It seems it is logging more than the maximum lines for command prompt. I've increased it to max (9999) and will try and get as much as possible

I've managed to run it again and this time got all the logs (I think). I've created a seperate gist for these: https://gist.github.com/TheOtterlord/bc3d59c97e044f726f65cbefe1de488e

Hm unfortunately I can't see anything that went wrong there. That looks like a normal termination of a connection?

Are you able to clone that URL with the git CLI? If so perhaps net.git-fetch-with-cli would work for you?

Just tried the git CLI and it failed to resolve with the following error.

Cloning into 'crates.io-index'...
remote: Enumerating objects: 275, done.
remote: Counting objects: 100% (275/275), done.
remote: Compressing objects: 100% (268/268), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

I'm guessing this means that the problem is related to git rather than cargo?

I also tried the net.git-fetch-with-cli and that failed with this error.

    Updating crates.io index
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  process didn't exit successfully: `git fetch --tags --force --update-head-ok https://github.com/rust-lang/crates.io-index refs/heads/master:refs/remotes/origin/master` (exit code: 128)
--- stderr
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

Yes if the git CLI can't clone this and Cargo can't clone this then it's likely an issue with your network configuration, perhaps a firewall or something like that?

Don't think I have anything like that and I seem to be able to clone other repositories. I'm just cloning the Flutter repo to check it's not a size related issue (as all of mine are small).

Yep, it seems it is failing on bigger repos. Probably due to some sort of request timeout or something. I'm not sure this is really a Cargo issue anymore so I'll close this. Now I have narrowed it down to some sort of network error related to big repos, I'll try to find a solution from there.

Thanks so much for helping me. Enjoy your day 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mathstuf picture mathstuf  路  3Comments

ckaran picture ckaran  路  3Comments

fprijate picture fprijate  路  3Comments

dotnetspec picture dotnetspec  路  3Comments

alilleybrinker picture alilleybrinker  路  3Comments