离线安装ruby gems/代理配置 [英] Install ruby gems offline / proxy configuration
问题描述
我需要在没有连接到Internet的服务器上的Rails + Nokogiri,httparty,json [和一些不太重要的gems]上安装ruby.怎么做?
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?
主机操作系统是Windows
host operating system is windows
其他问题,嗯,这对我来说不是很好,因为它可能需要几天的时间,但是作为客户,我可以向该服务器授予对http代理的访问权限.但是我必须承认,我已经尝试过使用类似的东西
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"
或
gem --http_proxy "http://username:password@host:port"
,但在两种情况下均无法访问gem store:(
but in both cases was not able to access the gem store :(
推荐答案
快速解决方案:
gem install -p http://proxy_ip:proxy_port rails
是一种快速且有效的方法,但每次安装我都需要永久性的东西.
is a fast and working way but I needed something permanent for every installation.
-
创建文件:
Create a file:
vi ~/.gemrc
添加内容
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
验证代理是否出现在gem环境变量中
Verify proxies appear in gem environment variables
gem env
RubyGems环境:-RUBYGEMS版本:2.5.2-橄榄球版本:2.3.3(2016年11月21日补丁程序级别222)[universal.x86_64-darwin17]
这篇关于离线安装ruby gems/代理配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!