問題
vagrant up
しようとすると以下のエラーが発生
A VirtualBox machine with the name 'homestead-7' already exists.
Please use another name or delete the machine with the existing
name, and try again.
日本語に直すと
「homestead-7という名前の仮想マシン名が既に存在するので他の名前を使うか、既に存在する名前の仮想マシンを削除するかをして、再び試してください」
とのこと
解決策
①vagrant global-status --prune
上記のコマンドでVagrantの環境を確認する
$ vagrant global-status --prune
id name provider state directory
------------------------------------------------------------------------------
cd2734f default virtualbox saved /Users/userName/MyVagrant/MyCentOS
dba0fa1 default virtualbox poweroff /Users/userName/vagrant/ubuntu64_18
bdf825c homestead-7 virtualbox poweroff /Users/userName/Homestead
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date (use "vagrant global-status --prune" to prune invalid
entries). To interact with any of the machines, you can go to that
directory and run Vagrant, or you can use the ID directly with
Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
確認した後にエラーが出た名前のもの(今回はhomestead-7)を削除する。この後にvagrant up
をしてやる。これで解決しない場合は②を
②vagrant box list
でboxごと削除
上記のコマンドでboxの一覧を表示し、エラーが出た名前のboxを削除し、boxを再度追加。再度vagrant up
する。これで解決しない場合は③を
③vboxmanage list vms
上記のコマンドで仮想マシン一覧を表示
"homestead-7" {f9c95eed-b1ce-426d-ab90-e03f19b6d29f}
VBoxManage unregistervm f9c95eed-b1ce-426d-ab90-e03f19b6d29f --delete
で削除したのちにvagrant up
を行う。(僕は①、②を行っても解決しなかったのですが、この③の方法で解決しました)