Kha*_*din 24 gem bundle ruby-on-rails unicorn bundler
我有一个小型的网络应用程序,它使用了一堆宝石.其中一些仅用于test和development环境.现在,当我尝试使用以下命令在生产服务器上启动unicorn时,它会失败.
unicorn_rails -E production -D -c config/unicorn.rb
Run Code Online (Sandbox Code Playgroud)
我在日志文件中看到的错误是:
Refreshing Gem list
Could not find gem 'spork (>= 0.9.0.rc2, runtime)' in any of the gem sources listed in your Gemfile.
Try running `bundle install`.
Run Code Online (Sandbox Code Playgroud)
我在下面粘贴了我的gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'unicorn'
gem 'mongoid', '>= 2.0.0.beta.19'
gem 'devise'
gem 'cancan'
gem 'haml', '>= 3.0.0'
gem 'bson'
gem 'bson_ext'
gem 'formtastic'
gem 'bluecloth'
group :production do
gem 'capistrano'
end
group :development do
gem 'haml-rails'
gem 'hpricot', '0.8.2'
gem 'ruby_parser', '2.0.5'
gem 'less'
gem 'rspec-rails', '>= 2.0.1'
end
group :development,:test do
gem 'spork', '>=0.9.0.rc2'
gem 'mongoid-rspec'
end
group :test do
gem 'factory_girl_rails'
gem 'autotest'
gem 'cucumber-rails'
gem 'cucumber'
gem 'capybara'
gem 'shoulda'
gem 'database_cleaner'
gem 'test_notifier'
gem 'rspec', '2.0.1'
gem 'launchy'
end
Run Code Online (Sandbox Code Playgroud)
Bundler应该检测正确的环境并忽略其他宝石,对吧?现在,我正在删除服务器上默认组中没有的所有行以使其工作,但这是一个丑陋的黑客.
Kha*_*din 55
经过大量挖掘后,我找到了解决这个问题的方法.我所要做的就是bundle install --without development test在启动服务器之前运行.这会.bundle/config在rails根中添加一行文件BUNDLE_WITHOUT: test:development.现在,无论何时运行bundle install或启动服务器,它都会忽略这些组.
Bundler CLI允许您指定其gems包安装不应使用--without选项安装的组列表.要指定要忽略的多个组,请指定由空格分隔的组列表.
bundle install --without test bundle install - withoutout development test运行bundle install --without test后,bundler会记住你在上次安装中排除了测试组.下次运行bundle install时,没有任何--without选项,bundler会调用它.
此外,调用没有参数的Bundler.setup,或者调用require"bundler/setup"将设置所有组,除了你排除的那些--without(因为它们显然不可用).
| 归档时间: |
|
| 查看次数: |
13958 次 |
| 最近记录: |