rust-lang / cargo

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

Cargo build failed with spurious network error #6513

Open weiby3 opened 5 years ago

weiby3 commented 5 years ago

Problem error: failed to load source for a dependency on rand

Steps

$ cargo run --verbose
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): failed to send request: 无法与服务器建立连接
; class=Os (2)
warning: spurious network error (1 tries remaining): failed to send request: 无法与服务器建立连接
; class=Os (2)
error: failed to load source for a dependency on `rand`

Caused by:
  Unable 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 send request: 无法与服务器建立连接
; class=Os (2)

The chinese sentences above are "Unable to establish connection to server". I have check my firewall, cargo isn't blocked, and there is personal CA installed by Adguard, no proxy.

Notes OS: Windows 7 64bit, mingw64 with MSYS2 Output of cargo version: cargo 1.29.0

ratankaliani commented 11 months ago

Ran into the same issue as @Hongqin-Li, my .gitconfig was incorrect, replacing it fixed this issue!

Demoevery commented 10 months ago

Using gitoxide solved it for me cargo +nightly -Zgitoxide run

pengchenglv commented 7 months ago

edit .cargo/config.toml as follows to disable proxy. It works for me

[http]
proxy = ""