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

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
VirtualBoxを再インストール後Vagrant起動時に発生したNS_ERROR_FAILUREの解決手順をメモしました。
環境
- Vagrant 2.2.16
- VirtualBox 6.1.22 r144080
発生したエラー
実行ログ
zsh$ 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を実行しようとした際にエラーが発生しているようです。
zshThere was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
VirtualBoxで確認
VirtualBoxから起動を確認してみるとカーネルドライバーがインストールされていないというエラーが出ています。
zshKernel 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のアップデートの際にシステムソフトウェアアップデートの許可を実行していなかったことが原因でした。
システムソフトウェアアップデートを許可して解決
セキュリティとプライバシーを開く
システム環境設定
> セキュリティとプライバシー
を開きます。
実行許可
「開発元"Oracle Ameria, Inc."のシステムソフトウェアがアップデートされました。」の右側の許可
を実行します。
再起動の実施
再起動の案内が表示されるので任意のタイミングで再起動します。
「開発元 Oracle Ameria, Inc. のシステムソフトウェアがアップデートされました。」の右側の許可
を実行します。
Vagrantを再リロード
vagrant reload
コマンドでvagrantをリロードします。
zsh$ 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.
無事起動することができました。
Vagrantの記事Vagrant
- article
【まとめ】よく使う物だけを抜粋したVagrantコマンドの使い方とオプションの一覧まとめ
- article
vagrantで起動したVM内で立ち上げているDockerのVolume(MySQLデータ永続化)で書き込みエラーになる件の対処
- article
【解決方法】Vagrantで構築したUbuntu20.04へsynced_folder を設定した際に発生するマウントエラーの対処
- article
【設定方法】VagrantとVirtualBoxでUbuntu20.04の仮想環境をサクッと構築する手順
- article
【設定方法】VagrantとVirtualBoxでCentOS8の仮想環境をサクッと構築する手順
- article
【解決方法】Vagrantを起動した際に発生するumount: /mnt: not mounted.の対処について
- article
【解決方法】Cursor使えない?頻発する「Connection failed. If the problem persists ...」エラーの対処
- article
一瞬で表示!Next.js × Edge Runtimeで始める超低遅延サーバーレス開発
- article
Next.jsでSEO対策を強化するための5つのポイント + アンチパターンの回避策
- article
Docker開発の落とし穴:よくある失敗パターン10選+実践的な回避策
- article
社内開発でDockerを導入する際に考えるべき運用ポイント
- article
Kubernetes vs Docker Compose:どっちを選ぶべき?違いと使い分けについて紹介