The mind is like a parachute. If it doesn't open, you're meat.

ForgetMeNot: Maintaining a cache for local bundler installs

14 Oct 2013

Very often I find myself needing to install a certain set of gems without access to or sometimes without any network access.

Bundler allows you perform bundle install from a cache. All you need to do is put all your gems in a vendor/cache directory where your Gemfile is and bundler will look in there if you call it with –local:

bundle install --local

The really neat trick is that bundler will always update the cache if the vendor/cache directory is present. So doing a simple bundle install with an empty vendor/cache will net you an up-to-date cache you can take with you offline.

My typical use case for this is to use a Gemfile to describe my system’s gems (in really complicated cases there might be a couple of Gemfiles), add the vendor/cache directory, perform bundle install and commit everything but the Gemfile.lock file.

In the developer VM then the environment:update task will perform a local bundle install. This way we have easy and consistent gem updates across the whole team.

blog comments powered by Disqus