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 book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
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)