Bundler and different platforms for development and production

by: Michael Raidel | posted: December 29th, 2010

With the current version of Bundler (1.0.7) you have to watch out for platform specific gems when using different platforms for development and production. Bundler generates the lockfile (Gemfile.lock) with the specific version for the current platform which is ignored when using “bundle install” with the –deployment flag.

Workarounds

You could either not check in Gemfile.lock (not recommended) or not use the –deployment flag on deployment (which is used by default by bundlers’s capistrano recipe).

  # override the bundler flags in a capistrano deployment
  # config/deploy.rb
  require "bundler/capistrano"
  set :bundle_flags,       "--quiet"

Alternatively you could update the lockfile on all used platforms by doing “bundle install” on each of them and commit the updated version (only works if the bundle is not already frozen which you can check with “bundle config”). Bundler keeps adding the additional gems to the lockfile and doesn’t overwrite the gems of another platform.