Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Rails to exclude some bundled gems from plugin-loading?

I have a Rails application that uses Bundler for dependency management. I've got the following in my Gemfile:

# default group:
gem 'json'

group 'development' do
  gem 'my_profiler'
end

group 'test' do
  gem 'mocha'
end

group 'deployment' do
  gem 'foo'
end

I call Bundler.setup(:default, RAILS_ENV.to_sym) and Bundler.require(:default, RAILS_ENV.to_sym) in my initializers.

The problem is that since Bundler puts the gems into vendor/bundle/, Rails initializes all gems that have an init.rb, not just those for the current environment. How do I prevent Rails from automatically loading Foo's init.rb?

like image 466
James A. Rosen Avatar asked Aug 19 '10 16:08

James A. Rosen


2 Answers

You can use the --without flag to exclude environments

$ bundle install --without development test

http://gembundler.com/groups.html

like image 100
Petrik de Heus Avatar answered Sep 20 '22 00:09

Petrik de Heus


What version of bundler are you using? recent ones should not install in vendor

like image 44
Samer Buna Avatar answered Sep 20 '22 00:09

Samer Buna