Bundler ignores groups in rails apps

匆匆过客 提交于 2019-12-22 03:54:41

问题


This problem was fixed in 0.9.8, but seems to have recurred in the 1.x branch.

In my Gemfile I have a group for the test and development environments that use the rspec gems. On my production server rspec is not installed. I used the command bundle install --without test development in my rails app

Starting my rails app in production mode gives the exception:

Could not find gem 'rspec (>= 0)' in any of the gem sources listed in your Gemfile.

If I comment out the test group the same error happens with the development group.

The same problem exists if I start in development mode, then it tries to load the gems in the test group.

It seems that bundler completely ignores the environment groups and tries to load all gems in Gemfile:

    group :test do
      gem "rspec"
    end

    group :development do
      gem "rspec-rails"
    end


  versions:
  bundle 1.0.15
  rails 3.0.7
  ruby 1.9.2-p180

回答1:


I was having this problem too, the problem was that .bundle/config file had something like "--without development test" even tho I had never ran the bundle command with this parameters(maybe I cloned the repository from the Webbynode server and their system added this automatically for production...)

anyway, the fix was

rm .bundle/config
bundle install


来源:https://stackoverflow.com/questions/6314512/bundler-ignores-groups-in-rails-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!