X

A Bridge to the Cloud...

Getting Vagrant 2.2.6 working with VirtualBox 6.1 GA

Simon Coter
Senior Manager, Oracle Linux and Virtualization Product Management

On December 11th 2019, we've announced Oracle VM VirtualBox 6.1 Generally Available release.

This release introduced the cool option to get your Virtual Machines imported from Oracle Cloud Infrastructure; for further details on how-to get this done, you can see this blog-article:

VirtualBox 6.1 in action: Import Virtual Machines from Oracle Cloud Infrastructure

That said, an other important component for DevOps purposes, while using Oracle VM VirtualBox, is Vagrant; Vagrant and Vagrant Boxes allow to automate all the steps required to get VMs (and software on top) deployed on top of VirtualBox; actual latest release of Vagrant (2.2.6) does not recognize VirtualBox 6.1 as a provider.

The workaround to overcome this temporary limitation can be applied by following steps:

  • Edit:

/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/driver/meta.rb

  • Add 6.1 within the "driver_map" list, as in the example below:

@logger.debug("Finding driver for VirtualBox version: #{@@version}")
 driver_map   = {
  "4.0" => Version_4_0,
  "4.1" => Version_4_1,
  "4.2" => Version_4_2,
  "4.3" => Version_4_3,
  "5.0" => Version_5_0,
  "5.1" => Version_5_1,
  "5.2" => Version_5_2,
  "6.0" => Version_6_0,
  "6.1" => Version_6_1,
 }

  • Create:

/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/driver/version_6_1.rb

This file is also available here

  • Edit:

/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/plugin.rb

  • Add 6.1 within the "module Driver" section, as in the example below:

    # Drop some autoloads in here to optimize the performance of loading
    # our drivers only when they are needed.
    module Driver
      autoload :Meta, File.expand_path("../driver/meta", __FILE__)
      autoload :Version_4_0, File.expand_path("../driver/version_4_0", __FILE__)
      autoload :Version_4_1, File.expand_path("../driver/version_4_1", __FILE__)
      autoload :Version_4_2, File.expand_path("../driver/version_4_2", __FILE__)
      autoload :Version_4_3, File.expand_path("../driver/version_4_3", __FILE__)
      autoload :Version_5_0, File.expand_path("../driver/version_5_0", __FILE__)
      autoload :Version_5_1, File.expand_path("../driver/version_5_1", __FILE__)
      autoload :Version_5_2, File.expand_path("../driver/version_5_2", __FILE__)
      autoload :Version_6_0, File.expand_path("../driver/version_6_0", __FILE__)
      autoload :Version_6_1, File.expand_path("../driver/version_6_1", __FILE__)
    end

With those simple steps you'll be able to get "Vagrant 2.2.6" and "Oracle VM VirtualBox 6.1" correctly working together and you won't lose the functionalities of both products while working together.

Hope it helps!

Join the discussion

Comments ( 15 )
  • feixiong Friday, December 13, 2019
    Thank you very much, It works!

    I installed Vagrant with Homebrew
  • Augusto da Silva Costa Friday, December 13, 2019
    Thank you! I updated my Arch Linux today, and now I can use Vagrant again.
  • Chrono Friday, December 13, 2019
    Thanks, works on windows 10 too, you just have to find the files. Try "where.exe vagrant" to see where vagrant is installed, then find the files under that head.
  • Simon Friday, December 13, 2019
    Hi Chrono / All,

    thanks for your feedback.

    Simon
  • Daniel Monday, December 16, 2019
    Thanks.

    For Debian/Ubuntu, files installed from a last 6.0 package are here:
    /usr/share/rubygems-integration/all/gems/vagrant-2.2.6/plugins/providers/virtualbox/
  • Rick Tuesday, December 17, 2019
    This blog post needs more traction. Vagrant 2.2.6 and VirtualBox 6.1 is incompatible UNTIL you make this change. This blog post needs to be seen by more people.

    For Windows installations, Vagrant installation path is: C:HashiCorpVagrantembeddedgems2.2.6gemsvagrant-2.2.6pluginsprovidersvirtualbox
  • Mark Crocker Friday, December 20, 2019
    It didn't work for me with Vagrant 2.2.6 and Virtualbox 6.1.0 r135406

    A customization command failed:

    ["modifyvm", :id, "--draganddrop", "hosttoguest", "--clipboard", "bidirectional", "--vram", "16"]

    The following error was experienced:

    #
  • Simon Friday, December 20, 2019
    Hi Mark,

    I would suggest you to open an issue on GitHub to Vagrant for this (https://github.com/hashicorp/vagrant) ; my suspect is that it's due to the "--clipboard" because this option has changed on VirtualBox 6.1 CLI (to --clipboard-mode).
    Thanks

    Simon
  • Andrey Polyakov Wednesday, December 25, 2019
    File version_6_1.rb should contain this code:

    ```
    require File.expand_path("../version_6_0", __FILE__)

    module VagrantPlugins
    module ProviderVirtualBox
    module Driver
    # Driver for VirtualBox 6.1.x
    class Version_6_1 < Version_6_0
    def initialize(uuid)
    super

    @logger = Log4r::Logger.new("vagrant::provider::virtualbox_6_1")
    end
    end
    end
    end
    end
    ```
  • Simon Thursday, December 26, 2019
    Hi Andrey,

    thanks for your feedback.
    Even if nothing changes, I've updated the file attached to this blog entry based on your suggestion.
    That said, there are a couple of minor-issues that still have to be addressed (like the clipboard one).

    Simon
  • Taras Wednesday, January 1, 2020
    Big thanks to Simon and Andrey, works on win 10
  • Vincent Rubiolo Friday, January 3, 2020
    Thanks much for the fix Simon, this is excellent information.

    The issue that tracks this on the Vagrant side is https://github.com/hashicorp/vagrant/issues/11249.

    As of Dec 16th, if you run Vagrant from source (following https://www.vagrantup.com/docs/installation/source.html), you'll get the fix in. I tried it today and confirm it works with VirtualBox 6.1.0 (exact version string is 6.1.0_RPMFusionr135406, this is Fedora 31).
  • Marius Thursday, January 9, 2020
    For Fedora 31 with vagrant installed from the system repository, replace

    /opt/vagrant/embedded/gems/2.2.6/gems/

    with

    /usr/share/vagrant/gems/gems/

    for the commands provided
  • alex Saturday, January 18, 2020
    Thank you so much!
  • Zeljko Saturday, April 18, 2020
    Thanks for this great information. This work for me on fedora 31.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.