こんにちは、エンジニアのオオバです。
とある環境でvagrant up
したときのことです。
The "VBoxManage" command or one of its dependencies could not
be found. Please verify VirtualBox is properly installed. You can verify
everything is okay by running "VBoxManage --version" and verifying
that the VirtualBox version is outputted.If you're on Windows and just installed VirtualBox, you have to
log out and log back in for the new environmental variables to take
effect. If you're on Linux or Mac, verify your PATH contains the folder
that has VBoxManage in it.
というエラー。VirtualBoxのパスがおかしい的な事をおっしゃっています。
エラーに従ってVirtualBoxのバージョンを確認しようとvirtualbox --version
コマンドを打つと、以下のエラー。
/usr/local/bin/virtualbox: line 2: /Applications/VirtualBox.app/Contents/MacOS/VirtualBox: No such file or directory

Mac環境でNGINX・PHP・MySQLのローカル環境構築メモ
このVirtualBoxちょうど一年前くらいにを書いた時brew cask install virtualbox
でインストールしたと思いますが、おそらくApplicationフォルダからVirtualBox.app
を削除したのだと思われます。
なので再度brew cask install virtualbox
して、インストールしました。
Warning: Cask 'virtualbox' is already installed.
To re-install virtualbox, run:
brew cask reinstall virtualbox
このような感じでダメっぽいので、エラーの通りbrew cask reinstall virtualbox
と実行してみます。
installer: The install was successful.
🍺 virtualbox was successfully installed!
virtualbox --version
と実行すると、

とVirtualBoxマネージャーが表示されるので、正常にインストールされたようです。

バージョンは5.2.20でした。※執筆時点で最新バージョン
以前VagrantとVirtualBoxでローカル環境を構築したときの経験則から、この2つのバージョンの関係性は重要で相性が悪いとうまくいきませんでした。
ぼくの実績ベースだと以下の関係性でうまく行っています。
今回は一旦用意されている以下の環境でやってみます。
- VirtualBox 5.2.20
- Vagrant 1.9.7
とりあえずvagrant upしてみる
vagrant up
実行。
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
vagrant up --provider=PROVIDER
, which should give you a more specific
error message for that particular provider.
上記のようなエラー。
同じような症状の記事がありますが、結論やっぱりバージョンの組み合わせっぽいです。
とりあえず、以前成功したときの実績に近いバージョンに合わせみようと思います。
上述したとおり、VirtualBoxはbrewでインストールしたのですが、過去バージョンをインストールする方法がわからなかったので、直接インストーラーからインストールすることにします。
VirtualBox 旧バージョン - Mac
こちらのリストから、5.1.24が最も近そうなので、コチラをDLしてインストールしました。
VirutalBox5.1.24はMojaveに対応していない

すると、先日アップデートしたmacOS Mojaveに対応していないのか、このようなアラートが出ます。

一応Applicationフォルダには存在はしています。

一応実行してみると、やはりVirtualBox5.1.24はMojaveに対応していないようです。
その状態で試しにvagrant up
すると、、、
There was an error while executing
VBoxManage
, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp
やっぱりうまくは行きません。※当たり前です。
ということで、VirtualBoxのバージョンは最新の5.2.20で進めることにして、Vagrantのバージョンを上げて対応することにします。
brewでアップグレード
brew cask upgrade
を実行してVagrantをアップデートし、バージョン2.2.0になりました。
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 'vagrant-global-status (= 0.1.4)'
このようなエラーがでるので、エラーに従って一つずつコマンドを実行してみます。
vagrant plugin repair
を実行します。
Failed to automatically repair installed Vagrant plugins. To fix this
problem remove all user installed plugins and reinstall. Vagrant can
do this for you automatically by running the following command:vagrant plugin expunge --reinstall
Failure message received during repair:
Unable to resolve dependency: user requested 'vagrant-vbguest (= 0.14.2)'
とエラーが出るので、vagrant plugin expunge --reinstall
を実行します。
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:Unable to resolve dependency: user requested 'vagrant-vbguest (= 0.14.2)'
と、インストールされているプラグインは使えないよエラーが出ますので、最後の頼みvagrant plugin update
を実行します。
Updating installed plugins...
Updated 'vagrant-vbguest' to version '0.16.0'!
とvagrant-vbguest
のアップデートが成功しました。
先程失敗したコマンドを再度実行していきます。
vagrant plugin repair
を実行します。
Repairing currently installed global plugins. This may take a few minutes...
Installed plugins successfully repaired!
とインストール済みプラグインの修復に成功しました。
一旦このタイミングでvagrant up
を試してみます。
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:mount -t vboxsf -o dmode=777,fmode=777,uid=500,gid=500 var_www_server /var/www/server
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
このようなエラーが出つつも、vagrant status
で確認すると動いていることが確認できました。

このエラーはこちらの記事で解決できそうですが、それはまた次のタイミングで。
以上。

この記事が気に入ったらフォローしよう
- VirtualBox 5.2.20
- Vagrant 2.2.0
- macOS Mojave 10.14