4

Installed Vagrant via sudo apt-get install vagrant, and every time I try to run some vagrant command, such as vagrant init precise32 http://files.vagrantup.com/precise32.box I get the following error:

/home/novito/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- log4r (LoadError)
    from /home/novito/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /usr/bin/vagrant:2:in `<main>'

Not sure why rvm gets involved here, but oh well, I hope you guys can guide me on how to solve this.

7

When you installed Vagrant using apt-get it would have installed all its required dependencies for the standard Ubuntu-packaged version of Ruby. But your error message indicates that when you run vagrant it is trying to use a version of Ruby (and its Gems) that is managed by RVM rather than the system version, and your version of Ruby is missing at least one of its dependencies, log4r.

I think you have a few options:

  1. Revert to using the system (standard Ubuntu) version of Ruby by running something like rvm use system --default to reset RVM by default, and only change Ruby versions when you need to.
  2. Switch back to the system version just when running Vagrant, so run rvm use system before running vagrant in the same shell.
  3. Identify all the Ruby Gems that Vagrant depends on and manually install them in your RVM-managed Ruby installation. This would be a fiddly approach, though. It used to be possible to install Vagrant itself as a Ruby Gem, so you could have installed it in your RVM-managed Ruby installation, but that is not supported any more.

See the RVM command options documentation for more detail on controlling which version of Ruby you are using.

  • I still get this error, even when using the default Ubuntu ruby version. – Cerin Sep 18 '14 at 18:38
3

After I downloaded and installed Vagrant from the download page the error goes away.

  • Started following (swaeku.github.io/blog/2013/03/09/…) these steps and got the error. The binary from vagrant site is working without an issue. To install run "dpkg -i name_of_package.deb" – kode Feb 25 '14 at 20:09
0

I had this issue as well. As it turns out, apparently you need ruby 1.9.3. I had installed Vagrant from source with 2.0.0 and the aforementioned error occurred until I reinstalled the gem with ruby 1.9.3.

0

I had a old custom ruby environment installed in my home (~/.rbenv) and this apparently overrides all the default system Ruby packages. When I deleted that folder, Vagrant started working just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.