Ruby gem dependencies on offline server

2020-02-05 07:25发布

问题:

I have a server that is totally disconnected from the Internet (for some strange security reasons).

How can I make the Ruby dependencies to various gems work in that environment? It might work with Bundler, but how do I install Bundler using gem without a Internet connection?

回答1:

You can download bundler as a .gem file from rubygems and install it on the server with

gem install /path/to/bundler.gem

Then you can pack all gems required for your application into ./vendor/cache directory with

bundle package

If now you deploy your app (along with ./vendor/cache directory) to the server and run

bundle install --local

bundler won't go to rubygems, but instead will install all gems from ./vendor/cache directory.

See bundler-package docs for more information.