環境
- Windows 10
- VirtualBox 6.1.0
- Vagrant 2.2.6
状況
VirtualBox 6.1.0 と Vagrant 2.2.6 をインストールして、仮想マシンを管理しようとしたところ、以下のようなメッセージが表示されて仮想マシンが起動できませんでした。
どうやら、Vagrant 2.2.6 では VirtualBox 6.1.0 をサポートしていないようです。
$ vagrant up
The provider 'virtualbox' that was requested to back the machine
'core-01' 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.
解決方法
Oracle社の中の人が、以下の記事をポストされていました。
こちらの記事によると、3つのファイルを修正・作成すれば解決するようです。
早速試してみます。
元記事のファイルパスなどはLinux系OSをベースにした内容のようなので、Windwos 10のものに読み替える必要があります。
meta.rb を修正する。
meta.rbというファイルに、VirtualBox 6.1 の設定を追加します。
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\driver\meta.rb
このファイルの56~67行目に driver_map の記述がありますので、以下のような感じで 6.1 の設定を追加します。
# Instantiate the proper version driver for VirtualBox
@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,
}
version_6_1.rb を作成する。
続いて、以下のファイルを作成します。
meta.rb があるフォルダと同じ場所です。
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\driver\version_6_1.rb
ファイルの中身は以下にありますので、そのままコピペするなりして作成しましょう。
plugin.rb を編集する。
最後に plugin.rb を編集します。
C:\HashiCorp\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\plugin.rb
このファイルの52~62行目に module Driver の記述がありますので、以下のような感じで 6.1 の設定を追加します。
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
動作確認
これで準備は完了です。
vagrant up してみましょう。
$ vagrant up
Vagrant failed to initialize at a very early stage:
The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:
vagrant plugin repair
If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:
vagrant plugin expunge --reinstall
Or you may want to try updating the installed plugins to their latest
versions:
vagrant plugin update
Error message given during initialization: Unable to resolve dependency: user requested 'sahara (= 0.0.17)'
別のエラーが出てしまいました。
Plugin の初期化に失敗しているようです。
Plugin をアップデートして、無事に vagrant up できました。
$ vagrant plugin update
Updating installed plugins...
Updated 'vagrant-vbguest' to version '0.22.1'!
$ vagrant up
Bringing machine 'core-01' up with 'virtualbox' provider...