macOS Mojaveにしてvagrantが動かなくなったときにした対応

こんにちは、ぺたこ(@peta727)です

9月後半にリリースされた macOS Mojave ですが、そろそろ1ヶ月立ちますのでMacBook Proをアップデートしました

アップデートが終わったあと、一部の開発で利用している vagrant が動かなくなっていたので対応しました

対応したこと

  1. Oracle VM VirtualBox を5.2にアップデート
  2. Vagrant を 2.2.0 にアップデート

具体的な手順

VirtualBox のアップデート

Oracle VM VirtualBox より VirtualBox(5.2) をダウンロード

dmgファイルよりインストール

vagrant up を実行

❯ vagrant up
==>  Provider 'virtualbox' not found. We'll automatically install it now...
     The installation process will start below. Human interaction may be
     required at some points. If you're uncomfortable with automatically
     installing this provider, you can safely Ctrl-C this process and install
     it manually.
==>  Downloading VirtualBox 5.0.10...
     This may not be the latest version of VirtualBox, but it is a version
     that is known to work well. Over time, we'll update the version that
     is installed.
The download was interrupted by an external signal. It did not
complete.

どうやら、インストールしたVirtualBoxを認識していないみたいです

原因を調べるために、 vagrant status を実行してみます

❯ vagrant status
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

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.

Vagrantが古いため、VirtualBoxのバージョン5.0以下にしか対応していないようです

Vagrantのアップデート

www.vagrantup.com より Vagrant(2.2.0) をダウンロード

dmgファイルよりインストール

vagrant up を実行

❯ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
...

無事起動できました