How do I update Ruby Gems from behind a Proxy (ISA-NTLM)
Solution 1
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.
Solution 2
For the Windows OS, I used Fiddler to work around the issue.
- Install/Run Fiddler from www.fiddler2.com
Run gem:
$ gem install --http-proxy http://localhost:8888 $gem_name
Solution 3
This totally worked:
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
Solution 4
I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
- gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information
Solution 5
I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
gem install -p http://proxy_ip:proxy_port rails
using the -p
parameter to pass the proxy. I'm using Gem version 1.9.1.
Related videos on Youtube
Comments
-
scoopr about 4 years
The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project
-
iconoclast about 12 yearsI've gotten rubysspi to work, but there's a lot of fiddling required. If you want to use it from a Git Bash shell, you'll need an alias added to your .bashrc file, such as this:
alias gem='ruby -rspa `which gem`'
-
kayleeFrye_onDeck about 8 yearsIf you have proxy issues after doing the steps in most of these answers, try making sure
sudo
has access to your environment variables by adding the-E
switch, e.g.,sudo -E doSomething
-
-
spoulson about 15 yearsIt seems 'gem' fails to recognize backslashes in the proxy string, whether by http_proxy env var or --http-proxy argument. e.g. from my Ubuntu box --http-proxy http ://domain\\userid@server:port gives me the error: "invalid argument: --http-proxy ..."; Fortunately, my proxy server didn't require the domain specification and gem worked without it.
-
squillman about 15 yearsISA lets the admin specify a default domain to authenticate against. You can try to leave out the domain and just use your username like spoulson suggests. If your ISA admin has specified said default domain and your useraccount is in that domain, this should work for you (assuming there are no blocking rules on the firewall)
-
Gishu almost 15 yearsThanks this worked! Wonder why it didnt work when i tried the -p and --http-proxy command line args. It seems like the env var is what works.
-
Darren Bishop almost 14 yearsRead in a google group that 'apserver' is now 'NTLM Authorization Server'; shame that searching for the former doesn't redirect to that latter.
-
Matrich almost 14 yearsHi Jarin, I went to the link you provided in your comment and couldn't find that download. Is there any way I can download it from anywhere else?
-
Ian G over 13 years@spoulson You need to URI encode the backslash if you need the domain, e.g. http ://domain%5Cuserid@server:port.
-
atomicules over 13 years@Matrich as per Darren's comment. apserver is now renamed and found here: ntlmaps.sourceforge.net
-
atomicules over 13 yearsWorked a treat, much easier than ntlmaps and cntlm.
-
Polaris878 about 13 yearsThis worked for me. Note that Fiddler isn't needed in all situations. Just
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
is all that was needed for me. -
Ed Manet almost 13 yearsFYI, in Windows, you can add the set http_proxy line to gem.bat so that you don't have to remember to set the proxy each time.
-
Konrads almost 12 yearsThis is the least painful way of all tried. On Ubuntu/Debian, I do apt-get install cntlm, edit config and then export http_proxy="localhost:3128". Works!
-
egerardus over 11 yearsThis is the most up to date answer, it works with windows also. I had to add my username and password though: gem install --http-proxy http://[user]:[password]@[server]:[port]
-
Stef over 11 yearsawesome mate, been getting mad here, trying to figure out why it works fine in my Ubuntu virtual machine and not on Windows. Thanks heaps
-
Gary Tsui almost 11 yearsGot thru installation by replacing the proxy part to username:password@proxy_ip:proxyport
-
raycarr over 10 yearsTaking Benjamin Wootton's tip worked out great on my Windows 7 laptop connected to the corporate LAN. In the command line window at the DOS prompt I set the HTTP_PROXY as http: // localhost : 8888 (ignore the spaces) and then used my LAN username and Password for HTTP_PROXY_USER and HTTP_PROXY_PASS respectively.
-
Byscripts over 10 yearsI found the article in my backups and just re-published it with the same URL.
-
Subrat Pattnaik over 9 yearsWorks perfectly on windows as well. Thanks!
-
madlymad over 8 yearsI had to add the
proxy_ip
that is used forhttps
connections in order to work! Great :D (gem version 2.0.14) -
Majid Fouladpour over 8 yearsI could not install jekyll and kept getting
SSL_connect SYSCALL returned=5 errno=0 state=unknown state (https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/jekyll-3.0.0.gemspec.rz)
. This worked for me withgem install --http-proxy http://127.0.0.1:8580 jekyll
-
PJP over 8 yearsThe URL is still not available. When providing a link to an off-site, non-Stack Exchange site, summarize the salient parts here and give credit to that site. That way, when the link breaks, the important part is still here.
-
bgStack15 over 8 yearsI added an alias to my bash profile:
alias geminstall='gem install --http-proxy ${http_proxy}'
to make my life easier. -
Suriyaa about 8 yearsSite doesn't exist anymore!
-
Andrey Regentov almost 8 yearsBy the way, if your password contains special symbols, you should urlencode them. E.g. replace
@
with%40
etc -
Alek Davis over 7 yearsOn Windows 7, --http-proxy flag must go after the gem name, e.g. gem install <gemaname> --http-proxy yourproxy.address;port. Otherwise, it will complain about an invalid command-line switch.
-
ggiunta over 7 yearsWorks on Windows 10
-
Joseph about 6 yearsThis is what worked for me behind a corporate proxy. No fiddler needed. For example to install jekyll gem just run:
sudo gem install jekyll --http-proxy=http://web-proxy.company.com:8080
-
Jason Aller about 5 yearsWhen adding an answer to an older question with existing answers it is useful to explain what your answer adds that is new.
-
Shantonu about 5 yearsto specify command directly without detail reading all details (quick answers)
-
Shantonu about 5 yearsand, setting environment variable is not an option for everybody (when you do only one time update)
-
Nico Haase about 5 yearsPlease add all explanation to the answer itself, not to the comment section
-
DependencyHell over 4 yearsIn case it is working using
--http-proxy
but not with a.gemrc
file, it may come from thesudo
configuration. I had to check/etc/sudoers
file to add :Defaults env_keep = "http_proxy ftp_proxy"
before :Defaults env_reset
-
doublespaces over 2 yearsDon't worry, this answer is the exact information I was looking for, thank you.