vagrant box addに失敗したときのメモ

`vagrant box add`に失敗した

```shell-session
MYPC0024:universe nishizawa$ vagrant box add ubuntu16 ~/vagrant/images/ubuntu16.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu16' (v0) for provider:
    box: Unpacking necessary files from: file:///Users/nishizawa/vagrant/images/ubuntu16.box
The box failed to unpackage properly. Please verify that the box
file you're trying to add is not corrupted and try again. The
output from attempting to unpackage (if any):

bsdtar: Error opening archive: Failed to open '/Users/nishizawa/.vagrant.d/tmp/box1253f92d9a7afd5f3065f569c1827cf289ecb2dd'
```

`/Users/nishizawa/.vagrant.d/tmp`を掃除しても変わらなかったので
バージョン古くて開けないんじゃない？ってことで

```shell-session
MYPC0024:universe nishizawa$ brew cask info vagrant
vagrant: 2.0.1
https://www.vagrantup.com/
/usr/local/Caskroom/vagrant/1.9.1 (3 files, 80.3MB)
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/vagrant.rb
==> Name
Vagrant
==> Artifacts
vagrant.pkg (Pkg)
MYPC0024:universe nishizawa$ brew cask reinstall vagrant
==> Satisfying dependencies
==> Downloading https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask vagrant
==> Uninstalling Cask vagrant
==> Running uninstall process for vagrant; your password may be necessary
==> Running uninstall script uninstall.tool
==> The following files and directories will be removed:
==>     /opt/vagrant
==>     /usr/local/bin/vagrant
==>
==> Do you wish to uninstall Vagrant (Yes/No)?
==> The uninstallation process requires administrative privileges
==> because some of the installed files cannot be removed by a
==> normal user. You may now be prompted for a password...
==>
==>
==> Successfully uninstalled Vagrant.
==> Done.
==> Press any key to exit.
==> Uninstalling packages:
com.vagrant.vagrant
Password:
==> Installing Cask vagrant
==> Running installer for vagrant; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
==> installer: Package name is Vagrant
==> installer: Upgrading at base path /
==> installer: The upgrade was successful.
🍺  vagrant was successfully installed!
```

ついでにVirtualBoxも更新しておく。

```shell-session
MYPC0024:universe nishizawa$ brew cask info virtualbox
virtualbox: 5.2.0-118431
https://www.virtualbox.org/
/usr/local/Caskroom/virtualbox/5.1.14-112924 (3 files, 89.4MB)
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/virtualbox.rb
==> Name
Oracle VirtualBox
==> Artifacts
VirtualBox.pkg (Pkg)
MYPC0024:universe nishizawa$ brew cask reinstall virtualbox
==> Satisfying dependencies
==> Downloading http://download.virtualbox.org/virtualbox/5.2.0/VirtualBox-5.2.0-118431-OSX.
Already downloaded: /Users/nishizawa/Library/Caches/Homebrew/Cask/virtualbox--5.2.0-118431.dmg
==> Verifying checksum for Cask virtualbox
==> Uninstalling Cask virtualbox
==> Running uninstall process for virtualbox; your password may be necessary
==> Running uninstall script VirtualBox_Uninstall.tool
==>
==> Welcome to the VirtualBox uninstaller script.
==>
==> Warning! Found the following active VirtualBox processes:
==>  2960   503 VBoxXPCOMIPCD
==>  2962   503 VBoxSVC
==>  3004   503 VBoxHeadless
==>  3007   503 VBoxNetDHCP
==>
==>
==> We recommend that you quit all VirtualBox processes before
==> uninstalling the product.
==>
==> And the following KEXTs will be unloaded:
==>     org.virtualbox.kext.VBoxNetFlt
==>     org.virtualbox.kext.VBoxDrv
==>
==> And the traces of following packages will be removed:
==>     org.virtualbox.pkg.vboxkexts
==>     org.virtualbox.pkg.virtualbox
==>     org.virtualbox.pkg.virtualboxcli
==>
==> The uninstallation processes requires administrative privileges
==> because some of the installed files cannot be removed by a normal
==> user. You may be prompted for your password now...
==>
==> unloading org.virtualbox.kext.VBoxNetFlt
==> An error occurred durning 'sudo /sbin/kextunload -m org.virtualbox.kext.VBoxNetFlt', the
==> unloading org.virtualbox.kext.VBoxDrv
==> (kernel) Kext org.virtualbox.kext.VBoxNetFlt did not stop (return code 0x5).
==> An error occurred durning 'sudo /sbin/kextunload -m org.virtualbox.kext.VBoxDrv', there
==> Failed to unload one or more KEXTs, please reboot the machine to complete the uninstall.
==> (kernel) Kext org.virtualbox.kext.VBoxNetFlt can't unload - module stop returned 0xdc008
==> Failed to unload org.virtualbox.kext.VBoxNetFlt - (libkern/kext) kext (kmod) start/stop
==> (kernel) Can't remove kext org.virtualbox.kext.VBoxDrv; services failed to terminate - 0
==> Failed to unload org.virtualbox.kext.VBoxDrv - (libkern/kext) kext is in use or retained
Error: Command failed to execute!
==> Failed command:
/usr/local/Caskroom/virtualbox/5.1.14-112924/VirtualBox_Uninstall.tool --unattended
==> Standard Output of failed command:
Welcome to the VirtualBox uninstaller script.
Warning! Found the following active VirtualBox processes:
 2960   503 VBoxXPCOMIPCD
 2962   503 VBoxSVC
 3004   503 VBoxHeadless
 3007   503 VBoxNetDHCP
We recommend that you quit all VirtualBox processes before
uninstalling the product.
And the following KEXTs will be unloaded:
    org.virtualbox.kext.VBoxNetFlt
    org.virtualbox.kext.VBoxDrv
And the traces of following packages will be removed:
    org.virtualbox.pkg.vboxkexts
    org.virtualbox.pkg.virtualbox
    org.virtualbox.pkg.virtualboxcli
The uninstallation processes requires administrative privileges
because some of the installed files cannot be removed by a normal
user. You may be prompted for your password now...
unloading org.virtualbox.kext.VBoxNetFlt
An error occurred durning 'sudo /sbin/kextunload -m org.virtualbox.kext.VBoxNetFlt', there should be a message above. (rc=3)
unloading org.virtualbox.kext.VBoxDrv
An error occurred durning 'sudo /sbin/kextunload -m org.virtualbox.kext.VBoxDrv', there should be a message above. (rc=3)
Failed to unload one or more KEXTs, please reboot the machine to complete the uninstall.
==> Standard Error of failed command:
(kernel) Kext org.virtualbox.kext.VBoxNetFlt did not stop (return code 0x5).
(kernel) Kext org.virtualbox.kext.VBoxNetFlt can't unload - module stop returned 0xdc008017.
Failed to unload org.virtualbox.kext.VBoxNetFlt - (libkern/kext) kext (kmod) start/stop routine failed.
(kernel) Can't remove kext org.virtualbox.kext.VBoxDrv; services failed to terminate - 0xdc008018.
Failed to unload org.virtualbox.kext.VBoxDrv - (libkern/kext) kext is in use or retained (cannot unload).
==> Exit status of failed command:
#<Process::Status: pid 4229 exit 1>
Add Comment C
```

失敗した。
`(kernel) Can't remove kext org.virtualbox.kext.VBoxDrv; services failed to terminate - 0xdc008018.`
の行を見てプロセスを殺せなかったのかなと判断。
ゾンビプロセス＝長時間居ると仮定してpsのheadで確認。
（時間順に出ると勘違いしてたが実際にはCPU使用率順か）

```shell-session
MYPC0024:universe nishizawa$ ps aux | head
USER               PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
root             78470   7.5  0.3  2629176  50772   ??  Us   12:44PM  23:38.70 /Library/Application Support/TrendMicro/TmccMac/iCoreService_av -p 61301 -n 61100 /Library/Application Support/TrendMicro/common/lib/libTmAntiMalware.dylib
nishizawa        46842   6.1  1.0  2905060 161348   ??  S    水03PM   7:35.46 /Applications/iTerm.app/Contents/MacOS/iTerm2
nishizawa         3004   5.1 23.0  6458872 3865712   ??  U     11117  310:11.23 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment sekai_default_1488276348878_2825 --startvm 9b4f3273-eb3b-4821-ac42-d1f7ee314228 --vrde config
```
`/Applications/VirtualBox.app`のプロセスが怪しい。killする。

```shell-session
MYPC0024:universe nishizawa$ kill 3004
```

再度VirtualBoxの更新を試みる。

```shell-session
MYPC0024:universe nishizawa$ brew cask reinstall virtualbox
==> Satisfying dependencies
==> Downloading http://download.virtualbox.org/virtualbox/5.2.0/VirtualBox-5.2.0-118431-OSX.
Already downloaded: /Users/nishizawa/Library/Caches/Homebrew/Cask/virtualbox--5.2.0-118431.dmg
==> Verifying checksum for Cask virtualbox
==> Uninstalling Cask virtualbox
==> Running uninstall process for virtualbox; your password may be necessary
==> Running uninstall script VirtualBox_Uninstall.tool
==>
==> Welcome to the VirtualBox uninstaller script.
==>
==> And the following KEXTs will be unloaded:
==>     org.virtualbox.kext.VBoxNetFlt
==>     org.virtualbox.kext.VBoxDrv
==>
==> And the traces of following packages will be removed:
==>     org.virtualbox.pkg.vboxkexts
==>     org.virtualbox.pkg.virtualbox
Please enter nishizawa's password (unloading org.virtualbox.kext.VBoxNetFlt):==>     org.virtualbox.pkg.virtualboxcli
==>
==> The uninstallation processes requires administrative privileges
==> because some of the installed files cannot be removed by a normal
==> user. You may be prompted for your password now...
==>
==> unloading org.virtualbox.kext.VBoxNetFlt

==> unloading org.virtualbox.kext.VBoxDrv
==> Successfully unloaded VirtualBox kernel extensions.
==> Forgot package 'org.virtualbox.pkg.vboxkexts' on '/'.
==> Forgot package 'org.virtualbox.pkg.virtualbox' on '/'.
==> Forgot package 'org.virtualbox.pkg.virtualboxcli' on '/'.
==> Done.
==> Uninstalling packages:
==> Installing Cask virtualbox
==> Running installer for virtualbox; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
==> installer: Package name is Oracle VM VirtualBox
==> installer: Installing at base path /
==> installer: The install was successful.
🍺  virtualbox was successfully installed!
```

無事に`vagrant box add`できた。

```shell-session
MYPC0024:universe nishizawa$ vagrant box add ubuntu16 ~/vagrant/images/ubuntu16.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu16' (v0) for provider:
    box: Unpacking necessary files from: file:///Users/nishizawa/vagrant/images/ubuntu16.box
==> box: Successfully added box 'ubuntu16' (v0) for 'virtualbox'!
```