狛ログ

2018年4月7日土曜日

vagrant up で 「Failed to create the host-only adapter」が発生した場合の対応


オフィス狛 技術部のKoma(Twitterアカウントの中の人&CEO)です。

PHPのフレームワークである「Laravel」は Homesteadを利用し、簡単に開発環境を作成出来ます。

そう、簡単に作成出来るはずが・・・・ある端末(Windows10)で、「vagrant up」でエラー になりました。

$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: 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: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Querying NetCfgInstanceId failed (0x00000002)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(struct HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp

色々調べても全く原因が分からず、
そして、このエラーが出る端末が1台だけ、という事もあり、しばらくの間、塩漬けしていました。

そして、このエラーの事も忘れていた頃、とある方から、「たぶんウィルス対策ソフトが原因ですよ」と言われました。

そう言えば、エラーが出る端末だけ、他の端末と違って「ウイルスバスター」を使っています。

試しに、「ウイルスバスター」を一時的に止めて試してみると・・・・
$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 4040 (guest) => 4040 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
    homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "454dc8f8-9053-4aef-9e96-8c4a9fe71ea7", "--type", "headless"]

Stderr: VBoxManage.exe: error: The virtual machine 'homestead-7' has terminated unexpectedly during startup with exit code 1 (0x1).  More details may be available in 'C:\Users\hogehoge\VirtualBox VMs\homestead-7\Logs\VBoxHardening.log'
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, interface IMachine

エラーメッセージは変わったけど、まだダメです。

今回、Vagrant のプロバイダはVirtualBoxにしているのですが、
結論から言うと、
一度VirtualBoxをアンインストールして、「ウイルスバスター」が停止している状態で、VirtualBoxを再インストールする必要があります。
その上で、再度「vagrant up」試してみると、うまく行きました。
(再インストールから「vagrant up」まで、ウイルスバスターは停止させています。)

※一度、仮想環境まで作成出来れば、後はウイルスバスターが起動していても大丈夫です。

昔、こんなブログ記事(Unity で Internal compiler error。)を書いたことがありますが、
この時もウィルス対策ソフト(McAfee)が原因でした。 やはり、まだまだウィルス対策ソフトに困らされる事があるのですね・・・


, ,

0 件のコメント:

コメントを投稿