【问题标题】:Why is Ruby bundler (w/ whiskey_disk and RVM) complaining that an installed Gem is not >=0?为什么 Ruby 捆绑器(w/whisky_disk 和 RVM)抱怨安装的 Gem 不 >=0?
【发布时间】:2012-07-16 19:04:52
【问题描述】:

这是我的错误信息:

Running rake deploy:post_setup...
rake aborted!
You have requested:
  nokogiri >= 0

The bundle currently has nokogiri locked at 1.5.5.
Try running `bundle update nokogiri`

这条消息是否告诉我 1.5.5 不知何故不符合 ">= 0" 要求?这听起来不对。

如果我解释错了,我应该如何解释?

(Ruby 是 jruby-1.6.7.2,bundle 是 1.1.4。这个 rake 任务实际上是通过whiskey_disk 运行的,如果这很重要的话。)

== 八个月后 ==

我发现了同样的错误。再次尝试使用whiskey_disk,所以我怀疑这与whiskey_disk有关。

这次是使用 bcrypt gem。

3052 ~/dev/myproj$ bundle exec wd setup --to=grant
Deploying grant@<myserver>.com...
grant@<myserver>.com's password: 
Repository already cloned to [/home/grant/myproj].  Skipping.
Running rake deploy:post_setup...
rake aborted!
You have requested:
  bcrypt-ruby >= 0

The bundle currently has bcrypt-ruby locked at 3.0.1.
Try running `bundle update bcrypt-ruby`

再一次,到底是什么?我要求大于 0 的东西,它在抱怨,因为捆绑包有 gem,它大于 0!有什么问题?

Gemfile 仅包含 gem 'bcrypt-ruby' - 未指定版本。 3.0.1 版应该是完全可以接受的。

我尝试在目标服务器上执行bundle updatebundle update bcrypt-ruby,但都没有改变任何东西。

【问题讨论】:

  • 你能发布你的 Gemfile 和 Gemfile.lock 吗?你能把你的环境部分发布在你的 Bundler.require 或 Bundler.setup 中吗?

标签: ruby ruby-on-rails-3.2 rake bundler


【解决方案1】:

您可能没有使用正确的 ruby​​。 ssh 进入机器后检查which ruby 是否正在使用。如果您使用的是 rvm,我只会卸载系统 ruby​​。

【讨论】:

  • 我将默认 rvm 设置为正确的(我没有这样做),但它并没有改变结果。有什么方法可以验证它使用的是正确的吗?
  • 您可以尝试使用 debug=true 运行whiskey_disk 部署任务。例如rake deploy:now to=your_env debug=true
  • 卸载系统 ruby​​ 是行不通的。它仍然找不到 rvm ruby​​。
【解决方案2】:

问题归结为我的 RVM 的 Ruby 没有被 任何 远程命令使用。他们继续使用发行版的非 RVM Ruby。

因此,需要两个修复:

  1. 需要更改我的 .bashrc 中的 RVM 路径行:

    PATH=<strong>$PATH</strong>:$HOME/.rvm/bin # Add RVM to PATH for scripting

    需要更改以优先考虑 RVM,如下所示:

    PATH=$HOME/.rvm/bin:<strong>$PATH</strong> # Add RVM to PATH for scripting

  2. 我需要在我的 post_setup.sh 和 post_deploy.sh 脚本中加载 RVM,以便后续的 rake 命令将使用我的 RVM ruby​​。

    这是通过添加以下内容来实现的:

    # Load RVM into a shell session *as a function*
    if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
      # First try to load from a user install
      source "$HOME/.rvm/scripts/rvm"
    elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
      # Then try to load from a root install
      source "/usr/local/rvm/scripts/rvm"
    else
      printf "ERROR: An RVM installation was not found.\n"
      exit -1
    fi
    

    (后者显然不是我写的,考虑到它的精美程度。我从我公司的其他项目之一中提取了它,他们之前已经明确处理过这个问题。)

  3. 我还需要在我的 post_setup.sh 和 post_deploy.sh 脚本中运行 bundle install。这必须发生在 whisky_disk 开始运行 Rake 之前,因此将其包含在 Rake 脚本本身中是不够的。

现在我的whiskey_disk 部署工作顺利。

【讨论】:

    猜你喜欢
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多