René Nyffenegger
René Nyffenegger

Reputation: 40533

gem install XYZ locally (without connection to the internet)

I need to install win32-api and antlr3 on a computer without internet connection. Had it such a connection, I'd use gem like so:

gem install win32-api -r
gem install antlr3 -r

This won't obviously work. So, I thought there should be a way to download the gem and install it later, but I am not sure how I would proceed.

I found gem's which operator, which seemd to indicate the local location of a gem:

c:\>gem which antlr3
c:/tools/Ruby187/lib/ruby/gems/1.8/gems/antlr3-1.8.8/lib/antlr3.rb

however, it didn't work on win32-api:

c:\>gem which win32-api
ERROR:  Can't find ruby library file or shared library win32-api

although I have previously installed it.

Can someone hint at the right direction to go on from here?

Upvotes: 5

Views: 3461

Answers (3)

squarism
squarism

Reputation: 3307

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.

Upvotes: 1

srcspider
srcspider

Reputation: 11205

Try,

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

Upvotes: 11

Theo
Theo

Reputation: 132902

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.

Upvotes: 0

Related Questions