In a production environment, it is common to have restricted internet access on production hosts. This means that using the standard ‘gem install’ and pulling gems from the rubygems.org repository directly on that host is not an option.
What is needed is a way to use an internet-connected development host that matches the target production host architecture to download the exact list of gems (and their dependencies). Then a way to archive these gems and load them in bulk into the production host.
Copy gems from source host
First we archive the entire contents of the gem installation directory (cache, doc, gems, specifications).
gem list --local gemdir=`gem env | grep "\- INSTALLATION DIRECTORY" | awk -F ': ' {'print $2'}` echo "Going to archive gems from $gemdir" cd $gemdir ls tar cvfz /tmp/sourcegems.tgz *
Then copy “/tmp/sourcegems.tgz” to the target host by whatever means is available.
Copy gems to target host
Now extract that gems folder into the installation directory of the target host.
gem list --local gemdir=`gem env | grep "\- INSTALLATION DIRECTORY" | awk -F ': ' {'print $2'}` mkdir -p $gemdir echo "Going to extract gems to $gemdir" ls $gemdir tar xvfz sourcegems.tgz -C $gemdir ls $gemdir gem list --local
You should see that the resulting list of gems is the same as the source host.
REFERENCES
http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network (copying just cache directory, then running install local)
https://rvm.io/gemsets/exporting (export using rvm?)