Spurious network error when installing cargo

2024-03-04
2021-11-16

When installing cargo, the package is fetched from the built-in git library by default.

Error

terminal

$ cargo install cargo-generate --features vendored-openssl
...

warning: spurious network error (1 tries remaining): [28] Timeout was reached (download of `bitflags v1.3.2` failed to transfer more than 10 bytes in 30s)

Cause

When running cargo install, the package is fetched from the built-in git library by default.

Change the configuration so that Git can fetch it.

How to solve

Add the following config in ~/.cargo/config.toml.

config.toml

[net]
git-fetch-with-cli = true

Reference