rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.54k stars 2.38k forks source link

Cannot pull from crates.io on mint linux 20.3 #10762

Open JonathanWoollett-Light opened 2 years ago

JonathanWoollett-Light commented 2 years ago

Problem

On new install of mint 20.3 when attempting to run cargo install rusty-hook I receive

jonathan@jonathan-pc:~/Projects/testint-setup$ cargo install rusty-hook
    Updating crates.io index
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  SSL error: received early EOF; class=Ssl (16); code=Eof (-20)

Steps

  1. Install mint linux
  2. Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  3. Run any cargo command which requires pulling from crates.io (e.g. cargo build on a project with dependencies or cargo install <any package>).

Possible Solution(s)

No response

Notes

I first encountered this issue with an extremely minimal set of installed applications under an hour after doing a clean install.

Version

cargo 1.61.0 (a028ae4 2022-04-29)
release: 1.61.0
commit-hash: a028ae42fc1376571de836be702e840ca8e060c2
commit-date: 2022-04-29
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Linux Mint 20.3 (una) [64-bit]
weihanglo commented 2 years ago

It's hard to remote debug. The root cause varies from platform to platform. ehuss wrote a simple guide to follow if seeing SSL connection issue, as this may be the same issue as #9113.

weihanglo commented 2 years ago

Also, knowing how Rust is installed is also important.

JonathanWoollett-Light commented 2 years ago
  1. Boot from linuxmint-20.3-cinnamon-64bit.iso (https://linuxmint.com/edition.php?id=292)
  2. Establish ethernet or WiFi internet connection.
  3. Open terminal
  4. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  5. source $HOME/.cargo/env
  6. cargo install rusty-hook

Errors:

mint@mint:~$ cargo install rusty-hook
    Updating crates.io index
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  SSL error: received early EOF; class=Ssl (16); code=Eof (-20)

image

I believe this is the mcve.

weihanglo commented 2 years ago

Thanks for the clear example!

Here are more approaches to help investigate this issue:

JonathanWoollett-Light commented 2 years ago

It wouldn't seem any of these helps resolve the problem, here is full terminal output covering these (it is too long to include directly in this comment).

weihanglo commented 2 years ago

From line 259-264 of your output, looks like it's a general TLS error on Linux, not only happens with Cargo.

mint@mint:~$ git clone https://github.com/rust-lang/crates.io-index
Cloning into 'crates.io-index'...
remote: Enumerating objects: 418179, done.
remote: Counting objects: 100% (1462/1462), done.
remote: Compressing objects: 100% (653/653), done.
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

Having searched on the Internet, some suggest to increase post buffer size or do a apt install gnutls-bin. Maybe give it a shot?

JonathanWoollett-Light commented 2 years ago

So moving from Mint to Ubuntu fixes the issue with git clone https://github.com/rust-lang/crates.io-index but the issue with cargo install rusty-hook (and other crates.io operations) remains.

manoadamro commented 2 years ago

Same issue here. Fresh rust install, can't build hello world because it can't update from crates.io.

I've even cloned crates.io and set the default registry to that local one, in ~/.cargo/config.toml and myproject/.cargo/config.toml but it still wants to download the entire thing from scratch.

JonathanWoollett-Light commented 2 years ago

This seems to also be an issue with Ubuntu. My configuration here:

jonathan@jonathan-desk:~$ neofetch
            .-/+oossssoo+/-.               jonathan@jonathan-desk 
        `:+ssssssssssssssssss+:`           ---------------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 22.04 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Kernel: 5.15.0-46-generic 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Uptime: 39 mins 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Packages: 2041 (dpkg), 13 (snap) 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Shell: bash 5.1.16 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Resolution: 3840x2160 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   DE: GNOME 42.1 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM Theme: Adwaita 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Theme: Yaru-dark [GTK2/3] 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Icons: Yaru [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Terminal: gnome-terminal 
  +sssssssssdmydMMMMMMMMddddyssssssss+     CPU: AMD Ryzen 9 5900X (24) @ 3.700GHz 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      GPU: NVIDIA GeForce RTX 3060 Ti Lite Hash Rate 
    .ossssssssssssssssssdMMMNysssso.       Memory: 4326MiB / 128723MiB 
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`                                   
            .-/+oossssoo+/-.                                       

jonathan@jonathan-desk:~$ 
beshur commented 6 months ago

Same issue on Mac OS (13.6.3) Intel

furkansahin commented 5 months ago

I have the same issue in ubuntu 22.04. Interestingly, it's happening randomly. You can see an example run here https://github.com/furkansahin/frequency/actions/runs/8419571829/job/23052464174. Using git, I can easily clone and fetch the target repository, however, using cargo, it fails randomly. I could also validate that system date time is not an issue. Adding git-fetch-with-cli = true to cargo did not help either. The only solution I could find is adding retry = 5 parameter. It seems like continuous tries are solving the issue but this is not ideal. Anyone has an idea?