我正在尝试安装vagrant插件vbguest
,但在终端中遇到以下错误:
$ vagrant plugin install vbguest
Installing the 'vbguest' plugin. This can take a few minutes...
/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in `all=': undefined method `group_by' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:275:in `with_isolated_gem'
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:231:in `internal_install'
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:102:in `install'
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:62:in `block in install_plugin'
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:72:in `install_plugin'
from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:37:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run'
from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run'
from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:14:in `action'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:32:in `block in execute'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `each'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `execute'
from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute'
from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in `execute'
from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:268:in `cli'
from /usr/bin/vagrant:173:in `<main>'
我正在使用Virtual Box 5.0.18_Ubuntu r106667和ruby 2.3.0p0。我在尝试安装sahara
插件时也面临同样的问题。我该如何解决?
答案 0 :(得分:67)
是的,存在问题:Vagrant 1.8.1
PR修复:https://github.com/mitchellh/vagrant/pull/7198
修复程序应在Vagrant 1.8.2
中发布。
但在此之前你可以手动修补它。
以下是修复Vagrant 1.8.1
Ubuntu 16.04
下ruby 2.3.0
的步骤。
1。)使用the following contents创建文件vagrant-plugin.patch
:
---
lib/vagrant/bundler.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb
index 5a5c185..c4a3837 100644
--- a/lib/vagrant/bundler.rb
+++ b/lib/vagrant/bundler.rb
@@ -272,7 +272,6 @@ module Vagrant
# Reset the all specs override that Bundler does
old_all = Gem::Specification._all
- Gem::Specification.all = nil
# /etc/gemrc and so on.
old_config = nil
@@ -286,6 +285,8 @@ module Vagrant
end
Gem.configuration = NilGemConfig.new
+ Gem::Specification.reset
+
# Use a silent UI so that we have no output
Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do
return yield
2。)应用补丁:
sudo patch --directory /usr/lib/ruby/vendor_ruby/vagrant < vagrant-plugin.patch
修正了/usr/lib/ruby/vendor_ruby/vagrant/bundler.rb
。
答案 1 :(得分:18)
我没有修补,而是在ubuntu 16.04中使用vagrant v1.8.0修复了这个问题:
wget https://releases.hashicorp.com/vagrant/1.8.0/vagrant_1.8.0_x86_64.deb
sudo dpkg -i vagrant_1.8.0_x86_64.deb
vagrant plugin install vagrant-vbguest
当它被释放时,请密切注意并升级到1.8.2 ...... 享受!
答案 2 :(得分:8)
这已在最新版本的Vagrant中修复,因此请升级。
如果不能,请运行此命令来解决问题:
sudo sed -i'' "s/Specification.all = nil/Specification.reset/" /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb
注意:sudo
权限是必需的,或者不作为root运行。
这将根据PR (#7198)修补bundler.rb
个文件。
您应该根据此流浪者PR (#7404)将bundler
升级到至少1.12.5:
sudo gem install bundler --version ">= 1.12.5"
答案 3 :(得分:2)
我和另一个插件有同样的错误:vagrant-triggers
我找到了一个适用于/usr/lib/ruby/vendor_ruby/vagrant/bundler.rb
的补丁。
但是,为了安装包,vagrant进入一个大循环尝试无限制。
答案 4 :(得分:0)
因为到目前为止似乎没有人提到它,所以这里是Ubuntu 16.04的错误报告:https://bugs.launchpad.net/ubuntu/+source/vagrant/+bug/1562696
截至目前,没有人向16.04版本提供补丁,因此它似乎必须patch manually或download a fixed package。
答案 5 :(得分:0)
更新红宝石对我有用。 Ubuntu 16.04。 我遵循了本指南https://www.brightbox.com/blog/2017/04/25/updated-ruby-ubuntu-packages/