Bundler: Packaging gems into the git repository (offline installation)

Updated . Posted . Visible to the public.

Installing gems on a server that has no access to the internet (especially rubygems.org) requires to bundle the gems into the repository itself. This requires to adjust the bundle config in the repository.

  1. Execute the following commands to configure bundler:
bundle config set --local path vendor
bundle config set --local disable_shared_gems true

Note

For Bundler < 2 you have to omit the "set": bundle config --local name value.
See here: https://bundler.io/v1.17/man/bundle-config.1.html Show archive.org snapshot

This will create a file .bundle/config with the following content.

---
BUNDLE_PATH: "vendor/"
BUNDLE_DISABLE_SHARED_GEMS: "true"
  1. Change your .gitignore.
# Make sure to check in .bundle
# /.bundle/

/vendor/ruby
  1. Run bundle package and commit the changes together with all gems in vendor/cache/.

Afterwards you can run bundle install --local and install all gems without an internet connection. Changing gems in your Gemfile will automatically change the file in vendor/cache henceforth and no further bundle package is required.

Last edit
Florian Leinsinger
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2021-04-14 11:21)