Cargo on Windows behind a corporate proxy

折月煮酒 提交于 2019-12-01 16:26:46

问题


I think this is a very common issue among those who want to use Cargo with Windows at work; I have seen multiple GitHub issues and forum posts related to it, but none of the answers solved my problems.

Whenever I try to build some code pointing to a crates.io crate, I get the following error:

 Downloading <package>
error: unable to get packages from source

Caused by:
  failed to download package <package> from <package address>

Caused by:
  SSL connect error

What can I do to fix this? I know that Cargo can use the settings at .cargo/config and that the proxy details can be included there, but it doesn't work for me, with or without specifying the path for the certificate (I used the one distributed with curl), like below:

[http]
proxy = "http://user:password@proxy-address.xyz:port"
cainfo = "cert.pem"

[https]
proxy = "https://user:password@proxy-address.xyz:port"
cainfo = "cert.pem"

The proxy specified in the config file works for any other purpose.

I'm using Windows 7 64bit, Rust 1.11 GNU and Cargo bundled with it. How can I get this working? Currently I have to resort to downloading crate sources manually from their repositories and specifying paths = [...] for each of them in the Cargo config file.


回答1:


It appears that this is no longer an issue as of cargo 0.13 bundled with Rust 1.13 stable - I no longer need to manually download packages and put them in paths in cargo's config file.




回答2:


I had the same problem, and I solved simply setting environment variables http_proxy and https_proxy with http(s)://user:password@proxy-address.xyz:port.

The only annoiyng part is that, when you need to unset the proxy (e.g. when you are smart-working from another network without using company's VPN) you have to unset / delete those variables.



来源:https://stackoverflow.com/questions/39220694/cargo-on-windows-behind-a-corporate-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!