Install ruby gems offline / proxy configuration

醉酒当歌 提交于 2021-02-07 07:34:18

问题


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


回答1:


I solved it this way:

set http_proxy=host:port

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




回答2:


This did the trick for me.

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




回答3:


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]




回答4:


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.




回答5:


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.




回答6:


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



来源:https://stackoverflow.com/questions/16959060/install-ruby-gems-offline-proxy-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!