Help us understand the problem. What is going on with this article?

「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.」が出た時の対処法

問題

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を行う。(僕は①、②を行っても解決しなかったのですが、この③の方法で解決しました)

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away