nil的未定义方法大小:gem安装中的NilClass

时间:2013-10-17 22:00:19

标签: ruby gem rubygems vagrant bundler

在Mac 10.8.5上运行VMWare Fusion 6。试图安装vagrant-vmware-fusion插件并得到此错误。我认为这是一个红宝石问题,但我不确定,因为我没有使用Ruby的经验。任何帮助将不胜感激。

vagrant plugin install vagrant-vmware-fusion
Installing the 'vagrant-vmware-fusion' plugin. This can take a few minutes...
/Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader/entry.rb:127:in `read': undefined method `size' for nil:NilClass (NoMethodError)
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader/entry.rb:126:in `read'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader/entry.rb:126:in `read'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:73:in `block (2 levels) in from_io'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:64:in `block in each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `loop'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_input.rb:138:in `block (2 levels) in each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:28:in `new'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_input.rb:137:in `block in each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:64:in `block in each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `loop'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_input.rb:132:in `each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:66:in `block in from_io'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package/tar_input.rb:22:in `open'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/package.rb:44:in `open'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:62:in `from_io'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:46:in `block in from_file_by_path'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:45:in `open'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/format.rb:45:in `from_file_by_path'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:119:in `format'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:129:in `spec'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:386:in `ensure_required_ruby_version_met'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:156:in `install'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/install_gem.rb:49:in `block in call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/install_gem.rb:39:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builder.rb:116:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `block in run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/busy.rb:19:in `busy'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/base.rb:17:in `action'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/install.rb:27:in `execute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/root.rb:52:in `execute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/cli.rb:38:in `execute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/environment.rb:478:in `cli'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/bin/vagrant:96:in `<top (required)>'
from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'
from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `<main>'

1 个答案:

答案 0 :(得分:0)

正确的答案是上面说的其他人:宝石包破了,你需要从互联网上获得一个合适的包,然后安装它。 Here是类似的问题,宝石作者建议只更新gem:

  

错误似乎发生在&#34;解开&#34;宝石包。这似乎表明它试图解压缩的包文件已损坏。鉴于untar源代码在2年内没有在rubygems中更改,并且它适用于其他所有人,这个问题特定于您的安装。

     

在您的情况下,所有其他宝石都可以正常工作,因此只有此文件已损坏。我认为在下载/解压缩文件时出现了问题。它可能已将此损坏的文件存储在某处。您可能需要确定它的位置,以便删除它。之后,rubygems应该尝试再次下载,之后安装应该按预期工作

因为人们建议删除所有的cachged包:

$ find -name "package.gem" -exec rm -f {} \;

然后在你有一个良好的互联网线路的地方下载宝石:

$ gem fetch package.gem

将gem复制到源项目文件夹中,然后安装它:

$ gem install ./package.gem

如果成功安装,请将其复制到bundler缓存(在我的情况下,它位于.bundle文件夹中),所以:

$ mv ./package.gem ./.bundle/cache/

然后发出bundle

$ bundle