Vagrant 无法使用请求的机器,因为它已锁定

问题描述 投票:0回答:7

我尝试访问我在宅基地建立的项目网站,它们以前工作得很好,而且我已经有几个星期没有在它们上工作了,但是今天当我尝试访问它们时我无法访问它们打开网站。我尝试运行 vagrant ssh 但出现此错误:

  VM must be running to open SSH connection. Run `vagrant up`
  to start the virtual machine.

当我尝试 vagrant up 时,我得到:

  Vagrant can't use the requested machine because it is locked! This
  means that another Vagrant process is currently reading or modifying
  the machine. Please wait for that Vagrant process to end and try
  again. Details about the machine are shown below:

  Name: default
  Provider: virtualbox

当我这样做时:

 vagrant status 'idOfTheMachine'

我得到:

vagrant status 'idOfTheMachine'
/Users/myName/Homestead/Vagrantfile:4: warning: already initialized constant VAGRANTFILE_API_VERSION
/Users/myName/Homestead/Vagrantfile:4: warning: previous definition of VAGRANTFILE_API_VERSION was here
Current machine states:

default                   poweroff (virtualbox)

The VM is powered off. To restart the VM, simply run `vagrant up`

当我打开 virtualbox 并尝试查看共享文件夹时,我可以在终端中看到共享文件夹,但看不到其中的项目。我已经用谷歌搜索过这个问题,但找不到任何解决方案。我是否应该销毁虚拟机上的宅基地机器并制作一个新机器,如果是这样,如何正确制作它,以便我在新机器上拥有相同的项目?

laravel vagrant virtual-machine homestead
7个回答
20
投票

我也有这个问题,虽然我不明白它是如何/为什么发生的,但我确实发现正在运行

vagrant reload {boxid}

通常会打开盒子并允许我连接到它。

您可能像我一样,在完成编码以释放资源时“流浪停止”您的盒子,并期望能够通过“流浪向上”轻松地重新打开它,但情况似乎并非如此。希望这能让您重新站起来,并且其他知道发生了什么的人可以解释为什么会发生这种情况。


10
投票

在 Windows 上,我杀死了 Ruby 进程,然后能够成功运行“vagrant stop”,然后运行“vagrant up”。


9
投票

这个问题只浪费了一个小时。我的最终解决方案:

  1. 从 Virtualbox 中删除机器
  2. 删除包含 Vagrantfile 的目录中的
    .vagrant
    文件夹(如果存在)
  3. 如果您仍然收到错误(就像我一样),请运行
    vagrant global-status
    检查是否有任何仍可识别的机器
  4. 如果机器仍然列出,请运行
    vagrant global-status --prune
    将其删除
  5. vagrant up
    应该可以再次工作

2
投票

在 Windows 上,使用“tasklist”找到“vagrant.exe”和“ruby.exe”的进程 ID。

现在使用“taskkill /PID /F”命令终止这两个进程。你已经准备好出发了。

运行“vagrant up”。

应该可以。


1
投票

在 MacOSX 上,我进入活动监视器并终止了正在运行的 vagrant 进程。这为我解决了问题。


0
投票

重新启动我的电脑修复了错误


0
投票

我通过在虚拟机应用程序中恢复虚拟机解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.