Install gem offline.

Problem :

You can not install gems if you have no network connection on machine or your machine is behind a very restrictive firewall that doesn’t have access to internet but still you want to install the gems.

 

Prerequisites :

If you try installing gems from local folder but sometimes it’s will not work because it requires all dependencies explicitly downloaded in local folder. (i.e. all dependant .gem files)

Gem installation from local folder needs all dependencies at local level.

 

Solution :

There is a way to download all such dependencies and pass on to a machine which doesn’t have access to internet and needs gems installations.

Below are the steps :

  1. Install the gems on an internet-connected computer to a temporary directory (say C:\tmp). Since we’re only interested in the files, also disable documentation generation:

gem install aws-sdk -i C:\tmp –no-rdoc –no-ri

  1. RubyGems has downloaded all the dependencies .gem files and placed them in gems/cache. i.e.

C:\tmp\cache

  1. Share the directory over FTP or any other means to target machine.
  2. On target machine(which doesn’t have access to internet), install all gems as follows.

gem install –force –local *.gem

Above steps will install the required gem on your machine.

Leave a comment