How to Use Bundler Behind a Proxy

How to use bundler behind a proxy?

OSX & Linux

export http_proxy=http://user:password@host:port
export HTTP_PROXY=$http_proxy

If it's using HTTPS, set it as well

export https_proxy=http://user:password@host:port
export HTTPS_PROXY=$https_proxy

If you use sudo, by default sudo does not preserves http proxy variable. Use -E flag to preserve it

$ sudo -E bundle install

to make sudo preserves environment variables by default:

https://memset.wordpress.com/2010/10/14/bash-http_proxy-from-a-user-environment-to-sudo-one/

Windows

As pointed by answers below, you can use SET instead

SET HTTP_PROXY=http://user:password@host:port
SET HTTPS_PROXY=%HTTP_PROXY%

setting bundler behind proxy

Hi you need to create the .gemrc file. To set the http proxy for RubyGems put the following in ~/.gemrc

---
http_proxy: PROXY_URL

Replace PROXY_URL with whatever you currently have in the http_proxy environment variable you mentioned.

How to bundle install a git gem behind a proxy?

Are you sure you are using git-over-http? I.e. does your git URL start with http://?

How do I update Ruby Gems from behind a Proxy (ISA-NTLM)

I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:

SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%PORT%

I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:

SET HTTP_PROXY=http://wolfbyte:secret@pigsy:8080

You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.

rails bundle install via proxy on windows

Here's what has worked for me:

Go to the system properties (right click "My Computer" > Properties).
In the advanced tab, look for the "Environment variables button".
Add a variable called http_proxy with the value http://username:password@proxyserver:port

Restart your console and you should be good to go.

A few caveats:

  • by experience, drop the domain in your username (if you have one)
  • some passwords will break this (e.g. passwords which contain an @ sign)


Related Topics



Leave a reply



Submit