Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing gems from behind a corporate firewall

I suspect that the corporate firewall is preventing gems from getting installed. I have HTTP_PROXY defined and I'm able to view remote gems via the following command:

jruby -S gem list -r

But when I go to install a gem, I get a 404:

jruby -S gem install rails

Is there a good workaround for resolving this issue other than maintaining an internal gem repository?

like image 349
digitalsanctum Avatar asked Dec 14 '09 19:12

digitalsanctum


2 Answers

for ruby gems, placing this in my gem.bat this works for me

@"%~dp0ruby.exe" "%~dpn0" %* --http-proxy http://domainname.ccc.com:8080

for jruby gems this works

@"%~dp0jruby.exe" "%~dpn0" %* -p http://domainname.ccc.com:8080

Also setting the environment variable works like

set http-proxy=http://domainname.ccc.com:8080

or if your proxyserver needs authentication

set http-proxy=http://user:password@host:port)

EDIT: for folks who have a very restrictive firewall or no internet accesss (eg on a server) you can do the following: install the gem(s) on a pc who has free access to internet, afterward you check the folder C:\Ruby193\lib\ruby\gems\1.9.1\cache and copy all the gems with a date last modified after the moment you did your install. On the target pc you copy them in the same folder or if you clean up afterward in your bin folder and start the install there with

c:\ruby193\bin\gem.bat install --local gemname-x.x.x.gem

gemname-x.x.x.gem being the gem filename of the base gem you want to install. The gem with all its dependencies should install. This is for windows, but other OS's can use the same technique, just adapt a few things. Success

like image 63
peter Avatar answered Sep 30 '22 17:09

peter


  1. Look in Internet Explorer proxy settings to find the name of your proxy server.
  2. Use the name of your proxy server in the -p option to the gem command.

    gem update rails -p http://mylocalproxy.mycompany.com

If this doesn't work, you can always set your own proxy server up on the internet somewhere.

like image 45
MattMcKnight Avatar answered Sep 30 '22 19:09

MattMcKnight