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
Rails4 Unknown Encoding Name - Cp720
Where Is the Rails Method That Converts Data from 'Datetime_Select' into a Datetime Object
Extract a Substring from a String in Ruby Using a Regular Expression
Include Jekyll/Liquid Template Data in a Yaml Variable
Ruby: How to Copy a Variable Without Pointing to the Same Object
Google Plus API Shutdown Today, Which Alternative Can Be Used to Authentication
Ruby Differences Between += and << to Concatenate a String
How to Remove a Key from Hash and Get the Remaining Hash in Ruby/Rails
Why Do I Get a "Permission Denied" Error While Installing a Gem
Ruby Method Lookup Path For an Object
How to Check If a Ruby Object Is a Boolean
Rails Each Loop Insert Tag Every 6 Items
Ruby Run Shell Command in a Specific Directory
Ruby on Rails Callback, What Is Difference Between :Before_Save and :Before_Create
Netbeans and Rails Error: Bin/Ruby: No Such File or Directory -- Script/Rails (Loaderror)
Ruby:Difference Between Instance and Local Variables in Ruby