Sergey Scherba
Sergey Scherba

Reputation: 511

Can't install vagrant plugins in Ubuntu

I was trying to install vagrant plugin vbguest, but got following errors in terminal:

$ 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>'

I am using Virtual Box 5.0.18_Ubuntu r106667 and ruby 2.3.0p0. I also faced the same problem trying to install sahara plugin. How can I fix it?

Upvotes: 41

Views: 15882

Answers (6)

Lingyong Sun
Lingyong Sun

Reputation: 19

updating ruby worked for me. Ubuntu 16.04. I followed this guide https://www.brightbox.com/blog/2017/04/25/updated-ruby-ubuntu-packages/

Upvotes: 0

Frederick Nord
Frederick Nord

Reputation: 1304

Because nobody seems to have mentioned it so far, here's the here's the bug report for Ubuntu 16.04: https://bugs.launchpad.net/ubuntu/+source/vagrant/+bug/1562696

As of now, nobody backported the patch for 16.04, so it seems to have to either patch manually or download a fixed package.

Upvotes: 0

kenorb
kenorb

Reputation: 166409

This is fixed in the recent version of Vagrant, so please upgrade it.

If you can't, run this command to fix the problem:

sudo sed -i'' "s/Specification.all = nil/Specification.reset/" /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb

Note: The sudo permission is required or run without as a root.

This will patch your bundler.rb file as per PR (#7198).

You should also upgrade your bundler to at least 1.12.5 as per this vagrant PR (#7404):

sudo gem install bundler --version ">= 1.12.5"

Upvotes: 8

Moosh
Moosh

Reputation: 396

I've same error with another plugin: vagrant-triggers

I've found a patch to apply on /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb.

but so, vagrant enter in a big loop an try infinitely to install the package.

Upvotes: 2

steinkel
steinkel

Reputation: 1186

Instead of patching, I fixed the issue using vagrant v1.8.0 in ubuntu 16.04:

  • Download package: 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

Keep an eye and upgrade to 1.8.2 when it's released... Enjoy!

Upvotes: 18

Eugen
Eugen

Reputation: 1485

Yes, there is an issue: https://github.com/mitchellh/vagrant/issues/7073 in Vagrant 1.8.1

PR with fix: https://github.com/mitchellh/vagrant/pull/7198

The fix should be released in Vagrant 1.8.2.


But until that you can patch it manually.

Here are the steps to fix Vagrant 1.8.1 under Ubuntu 16.04 which has ruby 2.3.0.

1.) Create file vagrant-plugin.patch with the following contents:

---
 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.) Apply patch:

sudo patch --directory /usr/lib/ruby/vendor_ruby/vagrant < vagrant-plugin.patch

which fixes /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb.

Upvotes: 67

Related Questions