Read more

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

Emanuel
April 14, 2021Software engineer at makandra GmbH

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

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more 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.

Posted by Emanuel to makandra dev (2021-04-14 13:21)