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

时间:2011-01-29 17:54:27

标签: ruby exception rvm failover vagrant

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

详细

  • MacBook运行10.6.5
  • rvm 1.1.0
  • 红宝石:1.8.7-p302,ree-1.8.7-2010.02,ruby-1.9.2-p0
  • Rake 0.8.7
  • 宝石1.3.7

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


我不完全确定错误的具体细节,但因为它可能是Veewee本身的一个问题。所以,我要做的是在veewee定义上构建一个新的基础。该命令失败并显示有关丢失方法的错误 - 但有趣的是 失败。

错误

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

这是两个不同的剪裁控制台输出。我把它们剪成了大小。每个错误的完整输出为available as a gist

安装了一个Ruby版本

当我在RVM中只有一个版本的Ruby(1.8.7)

时,这是命令运行
boudica:veewee john$ rvm rake build['mettabox'] --trace

rvm 1.1.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [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 (wayneeseguin@gmail.com) [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开发人员没有考虑这些事情。

2 个答案:

答案 0 :(得分:1)

由于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

答案 1 :(得分:0)

你提到的错误不是不同的ruby vms的问题。 可能是你升级到Virtualbox 4.X因为新流浪者需要它吗?

veewee所依赖的虚拟机的某些功能(尚未)移植到Virtualbox 4.x

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

帕特里克(veewee inspirator)