Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cargo on Windows behind a corporate proxy

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:[email protected]:port"
cainfo = "cert.pem"

[https]
proxy = "https://user:[email protected]: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.

like image 225
ljedrz Avatar asked Aug 30 '16 06:08

ljedrz


1 Answers

I had the same problem, and I solved simply setting environment variables http_proxy and https_proxy with http(s)://user:[email protected]: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.

like image 63
Marco Carlo Moriggi Avatar answered Sep 23 '22 17:09

Marco Carlo Moriggi