我仍然是rails/ruby/bundler的新手,我有点困惑。
在我们的config/application.rb
文件中,有这个捆绑程序片段:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
在我们的Gemfile
中,我们使用不同的组,例如
group :development, :test do
gem "rspec-rails", ">= 2.7.0", :group => [:development, :test]
gem 'shoulda-matchers'
gem 'watchr'
gem 'spork', '~> 1.0rc'
gem 'spectator'
gem 'debugger'
gem 'wirble'
end
但当我运行RAILS_ENV=production bundle install
(或bundle install --deployment
)时,它仍然会安装来自开发/测试小组的gem……
为什么会发生这种情况,或者我如何才能使其正常工作?
发布于 2012-06-06 18:46:00
看看--without
选项:
bundle install --without development test
默认情况下,Bundler安装所有gem,您的应用程序使用它需要的gem。Bundler本身对Rails和当前环境一无所知。
发布于 2017-06-14 17:57:09
另一种解决方案是使用bundle-only
ruby gem。它的使用方法如下:
> gem install bundle-only
> bundle-only production
这个库不会污染您的捆绑器配置,也不会增加Gemfile.lock
;它是bundler
提供的内置bundle --without every other group
选项的简单替代品。
https://stackoverflow.com/questions/10912614
复制相似问题