RVM 是否“故障转移”?到另一个 ruby​​ 实例时出错?

发布于 2024-10-14 19:21:31 字数 5927 浏览 12 评论 0原文

有一个奇怪的问题,我有一个 Rake 任务似乎正在使用多个版本的 Ruby。当一种失败时,它似乎会尝试另一种。

详细信息

  • MacBook 运行 10.6.5
  • rvm 1.1.0
  • Rubies:1.8.7-p302、ree-1.8.7-2010.02、ruby-1.9.2-p0
  • Rake 0.8.7
  • Gem 1.3.7

  • Veewee(使用 Opcode.com、Vagrant 和 Chef 配置虚拟机)


我不完全确定具体细节错误问题,但因为这可能是 Veewee 本身的问题。所以,我想做的是基于 veewee 定义构建一个新的盒子。该命令失败并出现有关缺少方法的错误 - 但有趣的是它如何失败。

错误

我设法弄清楚,如果我只使用 RVM 安装了一个 Ruby,它就会失败。如果我安装了多个 Ruby,它会在同一位置失败,但执行似乎会在另一个解释器中继续。

这是两个不同的剪辑控制台输出。我已将它们剪裁成尺寸。每个错误的完整输出可作为要点

安装了一个 Ruby 版本

这是当我在 RVM 中只有一个版本的 Ruby (1.8.7) 时运行的命令

boudica:veewee john$ rvm rake build['mettabox'] --trace

rvm 1.1.0 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build

…

creating new harddrive
rake aborted!
undefined method `max_vdi_size' for #<VirtualBox::SystemProperties:0x102d6af80>
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/dirty.rb:172:in `method_missing'

<------ stacktraces cut ---------->

/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19

多个 Ruby 版本

这是在 RVM 中提供三个版本的 Ruby 时运行的相同命令。在此之前,我使用了“rvm use 1.8.7”。再说一遍,我不知道特定错误的细节有多重要 - 我感兴趣的是存在三个独立的错误 - 每个错误都有自己的堆栈跟踪 - 并且每个错误都在不同的位置Ruby 解释器。查看每个堆栈跟踪的底部,您会发现它们都来自不同的解释器位置 - 首先是 ree-1.8.7,然后是 ruby​​-1.8.7,然后是 ruby​​-1.9.2:

boudica:veewee john$ rvm rake build['mettabox'] --trace

rvm 1.1.0 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build

…

creating new harddrive
rake aborted!
undefined method `max_vdi_size' for #<VirtualBox::SystemProperties:0x1059dd608>
/Users/john/.rvm/gems/ree-1.8.7-2010.02/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/dirty.rb:172:in `method_missing'

…

/Users/john/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ree-1.8.7-2010.02@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ree-1.8.7-2010.02@global/bin/rake:19
(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build
isofile ubuntu-10.04.1-server-amd64.iso is available
["a1b857f92eecaf9f0a31ecfc39dee906", "30b5c6fdddbfe7b397fe506400be698d"]
[]
Last good state: -1
Current step: 0
last good state -1
destroying machine+disks
(re-)executing step 0-initial-a1b857f92eecaf9f0a31ecfc39dee906
VBoxManage: error: Machine settings file '/Users/john/VirtualBox VMs/mettabox/mettabox.vbox' already exists
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Machine, interface IMachine, callee nsISupports
Context: "CreateMachine(bstrSettingsFile.raw(), name.raw(), osTypeId.raw(), Guid(id).toUtf16().raw(), FALSE , machine.asOutParam())" at line 247 of file VBoxManageMisc.cpp
rake aborted!
undefined method `memory_size=' for nil:NilClass
/Users/john/Work/veewee/lib/veewee/session.rb:303:in `create_vm'
/Users/john/Work/veewee/lib/veewee/session.rb:166:in `build'
/Users/john/Work/veewee/lib/veewee/session.rb:560:in `transaction'
/Users/john/Work/veewee/lib/veewee/session.rb:163:in `build'
/Users/john/Work/veewee/Rakefile:87
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:631:in `each'
…

/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19
(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build
isofile ubuntu-10.04.1-server-amd64.iso is available
["a9c4ab3257e1da3479c984eae9905c2a", "30b5c6fdddbfe7b397fe506400be698d"]
[]
Last good state: -1
Current step: 0
last good state -1
(re-)executing step 0-initial-a9c4ab3257e1da3479c984eae9905c2a
VBoxManage: error: Machine settings file '/Users/john/VirtualBox VMs/mettabox/mettabox.vbox' already exists
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Machine, interface IMachine, callee nsISupports
Context: "CreateMachine(bstrSettingsFile.raw(), name.raw(), osTypeId.raw(), Guid(id).toUtf16().raw(), FALSE , machine.asOutParam())" at line 247 of file VBoxManageMisc.cpp
rake aborted!
undefined method `memory_size=' for nil:NilClass
/Users/john/Work/veewee/lib/veewee/session.rb:303:in `create_vm'
/Users/john/Work/veewee/lib/veewee/session.rb:166:in `block in build'
/Users/john/Work/veewee/lib/veewee/session.rb:560:in `transaction'
/Users/john/Work/veewee/lib/veewee/session.rb:163:in `build'
/Users/john/Work/veewee/Rakefile:87:in `block in <top (required)>'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:634:in `call'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
…

/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:1992:in `run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/bin/rake:35:in `<main>'

直到我们到达最后安装的 Ruby 版本时,执行才会停止。

讨论

有谁知道这里发生了什么吗?以前有人见过这种类似“故障转移”的行为吗?对我来说,第一个异常不会像使用一个解释器那样停止执行,这似乎很奇怪,但我想知道安装 RVM 时是否会发生我们 Ruby 开发人员没有考虑到的事情。

Have a strange problem in that I have a Rake task that seems to be using multiple versions of Ruby. When one fails, it seems to try another one.

Details

  • MacBook running 10.6.5
  • rvm 1.1.0
  • Rubies: 1.8.7-p302, ree-1.8.7-2010.02, ruby-1.9.2-p0
  • Rake 0.8.7
  • Gem 1.3.7

  • Veewee (provisioning Virtual Machines using Opcode.com, Vagrant and Chef)


I'm not entirely sure the specific details of the error matter, but since it might be an issue with Veewee itself. So, what I'm trying to do is build a new box base on a veewee definition. The command fails with an error about a missing method- but what's interesting is how it fails.

Errors

I managed to figure out that if I only have one Ruby installed with RVM, it just fails. If I have more than one Ruby install, it fails at the same place, but execution seems to continue in another interpreter.

Here are two different clipped console outputs. I've clipped them for size. The full outputs of each error are available as a gist.

One Ruby version installed

Here is the command run when I only have a single version of Ruby (1.8.7) available in RVM

boudica:veewee john$ rvm rake build['mettabox'] --trace

rvm 1.1.0 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build

…

creating new harddrive
rake aborted!
undefined method `max_vdi_size' for #<VirtualBox::SystemProperties:0x102d6af80>
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/dirty.rb:172:in `method_missing'

<------ stacktraces cut ---------->

/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19

Multiple Ruby Versions

Here is the same command run with three versions of Ruby available in RVM. Prior to doing this, I used "rvm use 1.8.7." Again, I don't know how important the details of the specific errors are- what's interesting to me is that there are three separate errors- each with it's own stacktrace- and each in a different Ruby interpreter. Look at the bottom of each stacktrace and you'll see that they are all sourced from different interpreter locations- First ree-1.8.7, then ruby-1.8.7, then ruby-1.9.2:

boudica:veewee john$ rvm rake build['mettabox'] --trace

rvm 1.1.0 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build

…

creating new harddrive
rake aborted!
undefined method `max_vdi_size' for #<VirtualBox::SystemProperties:0x1059dd608>
/Users/john/.rvm/gems/ree-1.8.7-2010.02/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/dirty.rb:172:in `method_missing'

…

/Users/john/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ree-1.8.7-2010.02@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ree-1.8.7-2010.02@global/bin/rake:19
(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build
isofile ubuntu-10.04.1-server-amd64.iso is available
["a1b857f92eecaf9f0a31ecfc39dee906", "30b5c6fdddbfe7b397fe506400be698d"]
[]
Last good state: -1
Current step: 0
last good state -1
destroying machine+disks
(re-)executing step 0-initial-a1b857f92eecaf9f0a31ecfc39dee906
VBoxManage: error: Machine settings file '/Users/john/VirtualBox VMs/mettabox/mettabox.vbox' already exists
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Machine, interface IMachine, callee nsISupports
Context: "CreateMachine(bstrSettingsFile.raw(), name.raw(), osTypeId.raw(), Guid(id).toUtf16().raw(), FALSE , machine.asOutParam())" at line 247 of file VBoxManageMisc.cpp
rake aborted!
undefined method `memory_size=' for nil:NilClass
/Users/john/Work/veewee/lib/veewee/session.rb:303:in `create_vm'
/Users/john/Work/veewee/lib/veewee/session.rb:166:in `build'
/Users/john/Work/veewee/lib/veewee/session.rb:560:in `transaction'
/Users/john/Work/veewee/lib/veewee/session.rb:163:in `build'
/Users/john/Work/veewee/Rakefile:87
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:631:in `each'
…

/Users/john/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/bin/rake:31
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19:in `load'
/Users/john/.rvm/gems/ruby-1.8.7-p302@global/bin/rake:19
(in /Users/john/Work/veewee)
** Invoke build (first_time)
** Execute build
isofile ubuntu-10.04.1-server-amd64.iso is available
["a9c4ab3257e1da3479c984eae9905c2a", "30b5c6fdddbfe7b397fe506400be698d"]
[]
Last good state: -1
Current step: 0
last good state -1
(re-)executing step 0-initial-a9c4ab3257e1da3479c984eae9905c2a
VBoxManage: error: Machine settings file '/Users/john/VirtualBox VMs/mettabox/mettabox.vbox' already exists
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Machine, interface IMachine, callee nsISupports
Context: "CreateMachine(bstrSettingsFile.raw(), name.raw(), osTypeId.raw(), Guid(id).toUtf16().raw(), FALSE , machine.asOutParam())" at line 247 of file VBoxManageMisc.cpp
rake aborted!
undefined method `memory_size=' for nil:NilClass
/Users/john/Work/veewee/lib/veewee/session.rb:303:in `create_vm'
/Users/john/Work/veewee/lib/veewee/session.rb:166:in `block in build'
/Users/john/Work/veewee/lib/veewee/session.rb:560:in `transaction'
/Users/john/Work/veewee/lib/veewee/session.rb:163:in `build'
/Users/john/Work/veewee/Rakefile:87:in `block in <top (required)>'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:634:in `call'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
…

/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rake.rb:1992:in `run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/bin/rake:35:in `<main>'

It isn't until we reach the last installed version of Ruby that execution halts.

Discussion

Does anyone have any idea what's going on here? Has anyone seen this "failover"-like behavior before? It seems strange to me that the first exception would not halt execution as it did with one interpreter, but I wonder if there are things happening when RVM is installed that we Ruby developers are not considering.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷→糖丶微凉 2024-10-21 19:21:31

由于 rvm rake 应该在 RVM 的控制下针对所有版本的 Ruby 运行 rake 任务,我认为它正在执行预期的操作:rvm help 显示:

  rake       - runs a rake task against specified and/or all rubies

专门请求帮助 rake 显示:

$ rvm help rake
Rake

  RVM allows you to run rake tasks across multiple ruby versions, for example:

    ∴ rvm 1.8.6,1.9.1 rake spec

JSON Summary

  Adding a --json flag prior to the word 'rake' and a JSON summary will be printed out at the end of the run.

YAML Summary

  Adding a --yaml flag prior to the word 'rake' and a YAML summary will be printed out at the end of the run.

如果您尝试运行 rake 任务,则不必涉及 RVM。首先使用 RVM 设置所需的 Ruby 版本,然后运行任务:

rvm 1.9.2
rake some_task

Since rvm rake is SUPPOSED to run the rake task against all versions of Ruby under RVM's control I think it's doing what is expected: rvm help shows:

  rake       - runs a rake task against specified and/or all rubies

Specifically requesting help for rake shows:

$ rvm help rake
Rake

  RVM allows you to run rake tasks across multiple ruby versions, for example:

    ∴ rvm 1.8.6,1.9.1 rake spec

JSON Summary

  Adding a --json flag prior to the word 'rake' and a JSON summary will be printed out at the end of the run.

YAML Summary

  Adding a --yaml flag prior to the word 'rake' and a YAML summary will be printed out at the end of the run.

If you are trying to run a rake task, you do not have to involve RVM. Set your desired Ruby version with RVM first, then run the task:

rvm 1.9.2
rake some_task
仙气飘飘 2024-10-21 19:21:31

您提到的错误不是不同 ruby​​ 虚拟机的问题。
难道你升级到 Virtualbox 4.X 是因为新的 vagrant 需要它吗?

veewee 所依赖的 virtualbox 的一些功能(尚未)移植到 Virtualbox 4.x

我现在正在通过直接执行 virtualbox 命令来解决这个问题。有趣的是,在实施更新时,我遇到了完全相同的错误。

帕特里克(Veewee 灵感来源)

the error you are mentioning is not a problem of different ruby vms.
Could it be you have upgrade to Virtualbox 4.X because the new vagrant needs it?

Some functions of the virtualbox on which veewee is dependent are (not yet) ported to Virtualbox 4.x

I'm working around this now by execing the virtualbox commands directly. Funny that while implementing the update, I hit the exact same error.

Patrick (veewee inspirator)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文