Vagrant Up失败,因为名称已存在

ens*_*ger 9 wordpress virtual-machine web-development-server vagrant

我最近开始在我的本地Wordpress开发环境中使用Virtualbox,Vagrant和VVV.它很光滑.

我遇到的一个问题是,在关闭'流浪汉停止'之后,下次我开始'流浪汉'时我得到了这个错误:

==> default: Setting the name of the VM: vagrant-local 
The name of your virtual machine couldn't be set because VirtualBox
is reporting another VM with that name already exists. Most of the
time, this is because of an error with VirtualBox not cleaning up
properly. To fix this, verify that no VMs with that name do exist
(by opening the VirtualBox GUI). If they don't, then look at the
folder in the error message from VirtualBox below and remove it
if there isn't any information you need in there.

VirtualBox error:

VBoxManage.exe: error: Could not rename the directory 'C:\VirtualBox VMs\ubuntu-cloudimg-trusty-va
230_94704' to 'C:\VirtualBox VMs\vagrant-local' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component SessionMachine, interface IMac
VBoxManage.exe: error: Context: "SaveSettings()" at line 3015 of file VBoxManageModifyVM.cpp
Run Code Online (Sandbox Code Playgroud)

我访问列出的位置C:\ VirtualBox VMs \,实际上,该目录'vagrant-local'已经存在.如果我删除(或重命名)此目录并再次运行'vagrant up',则机器启动.但是,它还执行完整的配置过程.当然,这需要很长时间.

我正在使用VVV和Vagrant开箱即用的所有默认配置.我该怎么做才能帮助VirtualBox"正确清理"并认识到每次停止并重新启动时都不需要重新创建VM.

或者,我只是错过了什么?

如果不是首选,欢迎"初级"回复.我是这个领域的初学者,我很感激你的帮助!谢谢.


当前状态:我从C:\ VirtualBox VMs \中删除了有问题的VM; 以管理员身份运行Git Bash,我已经能够使用vagrant up(完全提供)vagrant halt,并且vagrant up再次使用预期结果(第二次没有配置up).截至目前,似乎一切正常.出现...... :)

小智 10

如果您使用的是Mac,vagrant destroy但无法正常工作,则会收到消息:The name of your virtual machine couldn't be set because VirtualBox is reporting another VM with that name already exists.然后您需要转到用户文件夹中的VirtualBox VMs文件夹并删除VM文件夹.

它处于一种奇怪的状态,它无法构建VM,因为它正在尝试为已经存在同名的文件夹创建设置.

  • 这是最好的答案。它与错误消息的第一行相关,它解决了问题。 (3认同)

Fré*_*nri 0

嗯..这是一个奇怪的问题。当你运行vagrant halt它时,只需发送信号来终止虚拟机。

Vagrant 将所有配置保存在一个.vagrant目录下(至少对于 mac os 和 linux,不完全确定是否是 windows),你不应该删除这个目录,因为它包含对你的虚拟机的所有引用,所以当你vagrant up下次运行时,vagrant 会搜索从该目录获取启动相应虚拟机的信息,并且它知道不需要重新创建虚拟机或配置。

删除有关虚拟机的信息的正确方法是运行vagrant destroy,它将删除所有 .vagrant 目录和虚拟机。

然后是从 .vagrant 和您的虚拟机再次建立此链接的方法,但这有点棘手,并且不确定它们是否得到官方支持

当你使用 vagrant 时,VirtualBox 应该变得(几乎)透明,你不需要启动它来使用你的虚拟机,一切都应该从 vagrant 运行(至少在初学者级别)

注意:在Windows上运行,如果以管理员身份运行应该没问题