6

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 :(

  • possible duplicate of [Ruby gem dependencies on offline server](http://stackoverflow.com/questions/11291235/ruby-gem-dependencies-on-offline-server) – Louis Kottmann Jun 06 '13 at 12:35
  • Got it at last, the correct answer is in http://stackoverflow.com/questions/4357895/offline-gem-dependencies – Vsevolod Semouchin Jun 06 '13 at 21:44
  • Almost there. It seems that it's `--http-proxy` (dash not underscore) and it is an option to `install` not an option to `gem`. `gem install --http-proxy "http://username:password@host:port" ` works for me. – Mort Nov 18 '16 at 19:16

6 Answers6

10

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 
    

    Save with ESC and then type :wq

  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]
madlymad
  • 6,367
  • 6
  • 37
  • 68
8

I solved it this way:

set http_proxy=host:port

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

timhecker
  • 93
  • 2
  • 8
8

This did the trick for me.

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

Vik
  • 3,495
  • 3
  • 22
  • 25
5

Navigate to the desired gem download page to be installed. For example, I was trying to install Sass, so I googled and reached sass 3.3.14. As I was behind my office proxy, I clicked Download link and downloaded the gem to a directory.

Next, via Ruby command line , navigated to the installed directory using pushd D:\Setups and used this :

D:\Setups> gem install sass --local

The desired gem should be installed.

ArNumb
  • 307
  • 1
  • 4
  • 10
4

You can download all the gems you needed(also there dependencies) from rubygems to your server,
then run gem install gem_name --local to install them.

leonhart
  • 1,193
  • 6
  • 12
4

For Proxy usage, Wolfbyte's answer worked for me. I'm running on Debian 7 (Wheezy).

How do I update Ruby Gems from behind a Proxy (ISA-NTLM)

I'll paste his answer below as well:

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.


In addition, my password had funny characters in it - those you have to URLEncode as per: http://www.cyberciti.biz/faq/unix-linux-export-variable-http_proxy-with-special-characters/

Hope this helps!

Colin

Community
  • 1
  • 1
Colin
  • 1,987
  • 3
  • 17
  • 21