无法更新生产服务器上的gem

pca*_*asa 31 ruby rubygems ruby-on-rails-3

无法更新生产服务器上的gem.

我试着bundle install --deploymentbundle install --without development test

但继续得到:

You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the Gemfile freeze 
by running `bundle install --no-deployment
Run Code Online (Sandbox Code Playgroud)

编辑

我不知道这是否正确,但需要快速修复.我跑了bundle install --no-deployment然后bundle update又跑bundle install --deployment

Rya*_*igg 46

说明可能有点令人困惑.它说你已经修改Gemfile了你的开发机器,只是推动了这些更改,而不是bundle install在提交更改之前运行.

通过运行,bundle install您将更新您的Gemfile.lock文件.这应该推送到你的服务器,因为它比它更重要Gemfile.考虑文件Gemfile的计划Gemfile.lock.

永远记得:

  1. 运行bundle install如果你改变了Gemfile,甚至只是为了确保.如果它太慢,则--local通过会强制它仅使用本地gem来解析其依赖关系.
  2. 提交双方GemfileGemfile.lock文件到你的资料库
  3. 部署GemfileGemfile.lock生成服务器以确保它们运行与开发环境完全相同的依赖项.

bundle update单独运行可能会被视为危险,它将更新应用程序的所有依赖项.如果您没有指定固定版本号,那么这主要是危险的Gemfile.我在这里写了这篇文章.


Tom*_*omL 9

FWIW我有这个问题,并通过从我的Gemfile中删除一些条件语句(OS上的条件)并重新运行bundle来修复它.


Jim*_*ood 7

仅供参考:如果您使用这样的源块,也可能会出现此错误:

source 'https://rails-assets.org' do
  gem 'rails-assets-jquery'
end
Run Code Online (Sandbox Code Playgroud)

你会在Gemfile.lock中看到这个gem的感叹号:

  rails-assets-jquery!
Run Code Online (Sandbox Code Playgroud)

只需正常定义其他来源,即

source 'https://rails-assets.org'
gem 'rails-assets-jquery'
Run Code Online (Sandbox Code Playgroud)

(顺便提一下这里关于使用多个宝石来源.)