Cargo fails with "spurious network error: The operation timed out" on Windows 10 when using a local user

Cargo fails with "spurious network error: The operation timed out" on Windows 10 when using a local user

我正在尝试在通常连接到我公司域的 Windows 10 笔记本电脑上为本地用户设置 Rust 编程环境。通过 rustup-init.exe 使用 rustup 安装稳定版本的 Rust 没有问题,但每次我尝试使用 cargo 安装工具或库时,我都会收到如下错误消息:

warning: spurious network error (5 tries remaining): [2/-1] failed to send request: The operation timed out

我公司的网络和家里的网络都会发生这种情况。我成功地为我的域帐户设置了 Rust。

我想这与网络有关,或者可能涉及我公司使用的 Sophos 软件 firewall/anti-virus;令我困惑的是,我尝试过的几乎所有其他与网络相关的实用程序都没有问题,从 gitcurl

我想使用这个额外的用户,因为我的公司对域用户阻止了一些实用程序,但对本地用户不阻止,例如 Dropbox。

对于我来说,我使用了一次代理,它被设置为CMD中的一个变量。
要显示您的代理设置,请在管理员命令中键入:

netsh winhttp show proxy

如果你有一个,你可以通过以下方式重置它:

netsh winhttp reset proxy

我没有明确的解释,但是 cargo 当连接到我办公室的 VPN 处于活动状态时可以正常工作。我想这确实与安全软件有关。

我花了一个小时试图解决这个问题并找到了 2 个可能的解决方案

  1. ssh 可能存在问题:依赖性,已通过启动 ssh 代理修复它:
eval `ssh-agent -s`
ssh-add
cargo build
  1. 在全局 ~/.gitconfig 中设置
[url "ssh://git@github.com/"]
    insteadOf = https://github.com/

~/.gitconfig 中删除它也解决了问题