无法在Ubuntu中安装vagrant插件

Ser*_*rba 41 ruby ubuntu virtualbox vagrant

我试图安装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>'
Run Code Online (Sandbox Code Playgroud)

我使用的是Virtual Box 5.0.18_Ubuntu r106667和ruby 2.3.0p0.我也遇到了同样的问题,试图安装sahara插件.我该如何解决?

arm*_*rma 67

是的,有一个问题:https://github.com/mitchellh/vagrant/issues/7073 inVagrant 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.)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
Run Code Online (Sandbox Code Playgroud)

2.)应用补丁:

sudo patch --directory /usr/lib/ruby/vendor_ruby/vagrant < vagrant-plugin.patch
Run Code Online (Sandbox Code Playgroud)

修正了/usr/lib/ruby/vendor_ruby/vagrant/bundler.rb.


小智 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 ...享受!


ken*_*orb 8

这是在最近版本的Vagrant中修复的,所以请升级它.

如果不能,请运行此命令来解决问题:

sudo sed -i'' "s/Specification.all = nil/Specification.reset/" /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb
Run Code Online (Sandbox Code Playgroud)

注意:sudo权限是必需的,或者不作为root运行.

这将bundler.rb根据PR(#7198)修补您的文件.

您还应该bundler根据此流浪者PR(#7404)将您升级到至少1.12.5 :

sudo gem install bundler --version ">= 1.12.5"
Run Code Online (Sandbox Code Playgroud)


小智 2

我对另一个插件也有同样的错误:vagrant-triggers

我找到了一个可以应用的补丁/usr/lib/ruby/vendor_ruby/vagrant/bundler.rb

但是,vagrant 进入一个大循环并无限尝试安装该包。