Thursday, March 5, 2015

Using Bundler in a Rake Task

If you want to use Bundler in a rake task to automate something like bundle install, you can't simply call bundle install in a system call. Fortunately, Bundler provides a method called Bundler.with_clean_env. Using that, you can do something like
 require 'bundler'  
 Bundler.with_clean_env  
  system 'bundle install'  
 end  
to run your task.