Spurious network error when installing cargo

Updated at

2024.3.4

Created at

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

mktia's note

Research & Engineering / Blockchain / Web Dev

© 2017-2025 mktia. All rights reserved.