Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install gem through proxy with authorization [duplicate]

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?

like image 827
Sergei Basharov Avatar asked Apr 25 '11 20:04

Sergei Basharov


People also ask

How do I install specific versions of gems?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

How does gem install work?

What does gem install do? gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):


2 Answers

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>

like image 120
jomayma Avatar answered Sep 25 '22 08:09

jomayma


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.

like image 29
Jatin Ganhotra Avatar answered Sep 22 '22 08:09

Jatin Ganhotra