Gemfile.local March 30, 2012

Bundler is excellent for managing dependencies of my applications but not for managing my custom dependencies. There are gems that I’d like to use locally, knowing their implications, without forcing that behavior on other developers or designers on the team. One such gem is rails-dev-boost, which speeds up my development environment considerably. Gemfile.local solves this limitation. Create Gemfile.local at Rails.root with the following content.

 1  eval File.read('Gemfile')
 2
 3  group :development do
 4    gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'
 5  end

Then execute these commands from Rails.root:

 $  cp Gemfile.lock Gemfile.local.lock
 $  BUNDLE_GEMFILE=Gemfile.local bundle
 $  echo "$(cat .gitignore)\nGemfile.local\nGemfile.local.lock" > .gitignore
 $  git commit -m "Added Gemfile.local to .gitignore." .gitignore

Whenever you need to use your custom Gemfile.local you can prepend the command with BUNDLE_GEMFILE=Gemfile.local bundle exec. For example, start the rails server by executing BUNDLE_GEMFILE=Gemfile.local bundle exec rails s and enjoy the benefits of your custom Gemfile.

blog comments powered by Disqus