Vagrant 2.2.6 Compatibility Solution for VirtualBox 6.1

Starting the Virtual Machine⌗
When starting the project development environment, the following error was displayed, showing that Vagrant only supports up to VirtualBox 6.0.
$ vagrant up
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:
Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:
4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0
A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.
So now let’s modify the Vagrant code to make it support the latest version of VirtualBox.
Modifying Vagrant Source Code⌗
plugin.rb⌗
# File path on macOS
/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/plugin.rb
# File path on Windows
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\plugin.rb
The modified content is as follows:
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
As shown above, a line autoload :Version_6_1, File.expand_path("../driver/version_6_1", __FILE__)
has been added to the Driver module.
meta.rb⌗
# File path on macOS
/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/driver/meta.rb
# File path on Windows
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\driver\meta.rb
The modified content is as follows:
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,
}
The last line "6.1" => Version_6_1,
has been added.
version_6_1.rb⌗
Create a version_6_1.rb file in the following directory:
# File path on macOS
/opt/vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/providers/virtualbox/driver
# File path on Windows
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\driver
And fill the version_6_1.rb file with the following content:
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
Now the modification is complete. Let’s quickly try if we can start the development environment in the project.
I hope this is helpful, Happy hacking…