Vagrant 抱怨“一台名为‘homestead-7’的 VirtualBox 机器已经存在”

Qaz*_*azi 4 virtualbox vagrant windows-10

每当我尝试运行此命令vagrant up时,都会遇到以下错误:

VirtualBox machine with the name 'homestead-7' already exists.
Please use another name or delete the machine with the existing name, and try again.
Run Code Online (Sandbox Code Playgroud)

我所做的,首先,我完美地配置了一切,这意味着我的 Vagrant 工作正常。我C: drive使用以下目录结构设置了所有内容。

C:/rec (contains my development Laravel code)
C:/recordings/Homestead (contains homestead files)
Run Code Online (Sandbox Code Playgroud)

当时我的Yaml配置是这样的 .homestead/Homestead.yaml

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub    
keys:
    - ~/.ssh/id_rsa
folders:
    - map: C:\rec
      to: /home/vagrant/Code
sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public
Run Code Online (Sandbox Code Playgroud)

直到上述状态,一切正常。但我决定将Homestead文件夹更改为我的文档文件夹,我在my document

git clone https://github.com/laravel/homestead.git Homestead
Run Code Online (Sandbox Code Playgroud)

Homestead在我的文档中创建了这样的目录C:\Users\SweetHome\Homestead

我打开此目录的命令行并运行此命令./init.bat我在.homestead目录中创建了所需的文件。但毕竟这一切,当我vagrant up在新创建的Homestead目录中运行命令时,它给了我错误

VirtualBox machine with the name 'homestead-7' already exists.
Please use another name or delete the machine with the existing name, and try again.
Run Code Online (Sandbox Code Playgroud)

如果我vagrant up在以前的/旧目录中运行,C:/recordings/Homestead一切都会正常工作。但在新的Homestead我面临错误。

指导我如何摆脱旧的Homestead,应该开始在新的Homestead. 我也尝试删除旧Homestead目录并运行vagrant up但同样的错误

以下是一些细节:

$ vagrant box list
laravel/homestead (virtualbox, 1.1.0)

$ vagrant --version
Vagrant 1.9.1


$ vagrant global-status
id       name        provider   state    directory
-----------------------------------------------------------------------------
5d103ba  homestead-7 virtualbox poweroff C:/Users/SweetHome/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. 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"
Run Code Online (Sandbox Code Playgroud)

Mei*_*hen 12

Homestead的Vagrantfile脚本尝试(通过调用scripts/homestead.rb脚本)创建一个默认名称为“homestead-7”的机器。这就是它失败的原因,如果具有该名称的框已经存在。

你有两种方法来解决这个问题:

  1. 打开 Oracle VirtualBox 并将现有机器(通过其设置)从“homestead-7”重命名为任何其他名称,然后vagrant up再次运行该命令。
  2. 在新机器name: SomeOtherNameHomestead.yaml文件中放置一行(用你想要的替换 'SomeOtherName'),脚本将使用该名称而不是 'homestead-7'(它没有记录,但在脚本中查看/ homestead.rb表明,它首先检查用户定义的名称,并使用它,否则,其采用默认的名称为“家园-7”: config.vm.define settings["name"] ||= "homestead-7"

  • 应该是公认的答案。完美运行。 (2认同)