8

I am behind a corporate proxy and it needs authorization to use it. When I try just to use option -p http://ip.of.my.proxy:3128, it throws error 407. Is there a workaround?

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335

2 Answers2

9

this solution works for me in analog situation (corporate network behind autenticated proxy):

  1. Create a file .gemrc under your HOME (in my case C:\Documents and Settings\my_username\.gemrc
  2. Write inside the previous file this single line:

http_proxy: http://<YOUR_USER>:<YOUR_PASSWORD>@<YOUR_PROXY_HOST>:<YOUR_PROXY_PORT>

jomayma
  • 99
  • 1
  • 2
  • 1
    More recent versions of rubygems no longer read the .gemrc file by default .. see the discussion here => https://github.com/rubygems/rubygems/issues/366 – Andrew Jan 09 '15 at 15:39
  • forked for me on Windows 8: gem --version 2.4.5.1 – rofrol Jan 05 '16 at 14:00
1

This is the way I figured it out. Hope it works for you too.

  1. Fill in the proxy in your Proxy settings(varies as per your system).
  2. Once, you are done with the proxy settings, just do (assuming a Linux system)
sudo -i gem install GEM_NAME

Note that the authorizationi.e username and password need to be filled in the proxy settings for the system.

If you are not the root user, or you wish to install the gem locally (if using RVM), don't use sudo then.

Jatin Ganhotra
  • 6,825
  • 6
  • 48
  • 71