Bundler忽略Rails应用程序中的组 [英] Bundler ignores groups in rails apps
问题描述
此问题已在0.9.8中修复,但似乎在1.x分支中再次出现。
This problem was fixed in 0.9.8, but seems to have recurred in the 1.x branch.
在我的Gemfile中,我有一个测试组,并且使用rspec gem的开发环境。
在我的生产服务器上未安装rspec。
我在
rails应用程序中使用了 bundle install --without-testing 的命令
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
在生产模式下启动我的Rails应用程序会出现以下异常:
Starting my rails app in production mode gives the exception:
在任何以下版本中都找不到gem'rspec(> = 0)'
您的Gemfile中列出了gem来源。
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.
如果我以开发模式启动,则会存在相同的问题,然后它会尝试在测试组中加载gem。
The same problem exists if I start in development mode, then it tries to load the gems in the test group.
似乎捆绑程序完全忽略了环境组,并尝试将所有gem加载到Gemfile中:
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
推荐答案
我在也是这个问题,问题在于.bundle / config文件有类似
的-没有开发测试
甚至我从未运行过带有此参数的bundle命令(也许我从Webbynode服务器及其系统会自动将其添加到生产环境中...)
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...)
无论如何,解决方法是
rm .bundle/config
bundle install
这篇关于Bundler忽略Rails应用程序中的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!