Windows Subsystem for Linux (WSL) にてvagrantを実行するときにハマったときのメモ

Windows Subsystem for Linux = Bash on WIndowsにてvagrantを使って開発環境を構築する際に引っかかったのでメモしておく。 基本的なインストール方法については色々なブログで書かれているので省略。

www.gosoly.com

Command: ["hostonlyif", "create"] error with windows 10

ホストオンリーアダプタの設定中にこける問題。

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available)
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(struct HandlerArg *)" at line 70 of file VBoxManageHostonly.cpp

GithubのIssueにて回避策が乗っていたので、それを適応したところ動いた。(私の環境だと設定後、再起動が必要だったが)

github.com

1. Goto C:\Program Files\Oracle\VirtualBox\drivers\network\
2. There are two folders, go inside both of them and right click on .inf and click Install
3. Head over to Control Panel\Network and Internet\Network Connections
4. Right click on Network Adapter and choose Properties
5. C lick on Install => Service
6. Under Manufacturer choose Oracle Corporation and under Network Service, choose VirtualBox NDIS6 Bridged Networking driver
7. Ok and Close

failed to create the raw output file (VERR_PATH_NOT_FOUND)

% vagrant up 
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> 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...
==> default: 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", "3a8e4eed-b3f0-4f53-acef-0a59c57abe96", "--type", "headless"]

Stderr: VBoxManage.exe: error: RawFile#0 failed to create the raw output file /mnt/c/Users/hoge/ubuntu-xenial-16.04-cloudimg-console.log (VERR_PATH_NOT_FOUND)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

シリアルポート接続の設定を上書きして、切断状態にすることで正常に起動するようになるとのこと。

config.vm.provider "virtualbox" do |vb|
  vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
end

stackoverflow.com