【解決方法】VirtualBoxをHomebrewで再インストール後Vagrant起動時に発生したNS_ERROR_FAILUREの対処

VirtualBoxVagrantエラー解消
【解決方法】VirtualBoxをHomebrewで再インストール後Vagrant起動時に発生したNS_ERROR_FAILUREの対処
Memo
この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

VirtualBoxを再インストール後Vagrant起動時に発生したNS_ERROR_FAILUREの解決手順をメモしました。

環境

  • Vagrant 2.2.16
  • VirtualBox 6.1.22 r144080

発生したエラー

実行ログ

terminal
$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'centos/8' version '2011.0' is up to date... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... 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 95 of file VBoxManageHostonly.cpp

VBoxManageのCLIの実行エラー

VagrantがVBoxManageのCLIを実行しようとした際にエラーが発生しているようです。

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

VirtualBoxで確認

VirtualBoxから起動を確認してみるとカーネルドライバーがインストールされていないというエラーが出ています。

Kernel driver not installed (rc=-1908)

Make sure the kernel module has been loaded successfully.

where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT. 
VirtualBoxのカーネルドライバーがインストールされていないというエラー

エラーの原因

システムソフトウェアアップデートの許可

VirtualBoxのアップデートの際にシステムソフトウェアアップデートの許可を実行していなかったことが原因でした。

システムソフトウェアアップデートを許可して解決

セキュリティとプライバシーを開く

システム環境設定 > セキュリティとプライバシーを開きます。

システム環境設定 > セキュリティとプライバシー

実行許可

「開発元"Oracle Ameria, Inc."のシステムソフトウェアがアップデートされました。」の右側の許可を実行します。

セキュリティとプライバシー設定画面

再起動の実施

再起動の案内が表示されるので任意のタイミングで再起動します。 「開発元"Oracle Ameria, Inc."のシステムソフトウェアがアップデートされました。」の右側の許可を実行します。

再起動の案内

Vagrantを再リロード

vagrant reloadコマンドでvagrantをリロードします。

terminal
$ vagrant reload ==> default: Attempting graceful shutdown of VM... ==> default: Checking if box 'centos/8' version '2011.0' is up to date... ==> 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: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! [default] GuestAdditions 6.1.22 running --- OK. ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Rsyncing folder: /Users/yuki.hayakawa/workspace/sakura-tools/ => /vagrant ==> default: Mounting shared folders... default: /var/www/app => /Users/yuki.hayakawa/workspace/sakura-tools ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run.

無事起動することができました。

終わりに

最後までご覧いただきありがとうございます。
この記事では【解決方法】VirtualBoxをHomebrewで再インストール後Vagrant起動時に発生したNS_ERROR_FAILUREの対処について紹介させていただきました。

これからも皆様の開発に役立つ情報を提供していきたいと考えています。
今後ともよろしくお願いいたします。