gem install XYZ locally (without connection to the internet)

本小妞迷上赌 提交于 2019-12-05 11:54:32

Try,

gem install --local path/to/file.gem

I had some problems with this on a VM. The VM intentionally did not have Internet access (sneaker-net test machine) but it still had some DNS servers configured.

For example:

$ gem install bundler-1.7.7.gem --local
ERROR:  While executing gem ... (Errno::ENETUNREACH)
    Network is unreachable - sendto(2) for "192.168.1.10" port 53

192.168.1.10 is the DNS server that VirtualBox configured. So what I had to do is comment out /etc/resolv.conf with ; at the beginning of all the lines. Even leaving in Google DNS would break it.

; /etc/resolv.conf
nameserver 8.8.8.8  ; nope.  gem install --local doesn't like it
; You will get a Network is unreachable - sendto(2) for "8.8.8.8" port 53

If you comment out all of /etc/resolv.conf then you can install gems locally (from a file) it seems.

$ gem install bundler-1.7.7.gem --local
Successfully installed bundler-1.7.7
Parsing documentation for bundler-1.7.7
Installing ri documentation for bundler-1.7.7
Done installing documentation for bundler after 4 seconds
WARNING:  Unable to pull data from 'https://rubygems.org/': no such name (https://rubygems.org/specs.4.8.gz)
1 gem installed

Ruby gems version: 2.4.4 on Ruby 2.1.5.

gem will first look in the current directory after .gem files. Try downloading the .gem files of the gems you want to install on a computer with an internet connection (and don't forget dependencies), then move the files over to the other computer and run gem install xyz in the same directory where you placed the .gem files.

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