Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install ruby gems offline / proxy configuration

I need to install ruby on rails + Nokogiri, httparty, json [and some less significant gems] on server which does not have connection to internet. How it could be done?

host operating system is windows

Additional question, well, it is not very good for me, since it can takes some days, but I can as customer to give this server access to the http proxy. However I must confess, that I already tried to use somethin like that

set http_proxy="http://username:password@host:port"

or

gem --http_proxy "http://username:password@host:port"

but in both cases was not able to access the gem store :(

like image 466
Vsevolod Semouchin Avatar asked Jun 06 '13 09:06

Vsevolod Semouchin


People also ask

How do I install gem packages?

With the --local ( -l ) option, you would perform a local search through your installed gems. To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.

How do I get RubyGems?

Open up the 'Software Center' app from your launcher and type in `RubyGems` without quotes into the application search box at the top right, and press [enter]. RubyGems then can be installed by just clicking on the button labeled 'Install', thats it.


2 Answers

Fast solution:

gem install -p http://proxy_ip:proxy_port rails

is a fast and working way but I needed something permanent for every installation.

Permanent solution:

  1. Create a file:

    vi ~/.gemrc
    
  2. Add contents

    # HTTP Proxy options
    http_proxy: http://proxy_ip:proxy_port
    https_proxy: http://proxy_ip:proxy_port
    # For authentication (although not tested)
    http_proxy_user: username
    http_proxy_pass: password
    https_proxy_user: username 
    https_proxy_pass: password 
    
  3. Verify proxies appear in gem environment variables

    gem env
    

RubyGems Environment: - RUBYGEMS VERSION: 2.5.2 - RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [universal.x86_64-darwin17]

like image 181
madlymad Avatar answered Oct 25 '22 02:10

madlymad


I solved it this way:

set http_proxy=host:port

without any quotes, http:// protocol and username:password. Cheers

like image 34
timhecker Avatar answered Oct 25 '22 03:10

timhecker