运行 Vagrant up 时出错

Error while running Vagrant up

最初,我有 8 台 vagrant 机器 运行,然后出了点问题。所以我删除了 ~/VirtualBox\ VMs 文件夹中的虚拟机,并将备份 .vmdk 文件放在同一位置。 然后我尝试 运行 vagrant up ... 但是我收到以下错误

将机器 'virtual-am1' 与 'virtualbox' 供应商联系起来...

==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
    virtual-am1: Adapter 1: nat
    virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
    virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
   A customization command failed:

["modifyvm", :id, "--name", "virtual-am1"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]

Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)

VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports

VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp

>Please fix this customization and try again.

这就是我的 Vagrantfile 的样子... 我们有一个自定义的 Vagrant 文件

# -*- mode: ruby -*-
# vi: set ft=ruby :

#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.insert_key = false

  config.vm.box = "centos653"
  config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
 # config.vm.provision :shell, path: "bootstrap.sh"

  nodes_config.each do |node|
    node_name   = node[0] # name of node
    node_values = node[1] # content of node

    config.vm.define node_name do |config|
      # configures all forwarding ports in JSON array
      ports = node_values['ports']
      ports.each do |port|
        config.vm.network :forwarded_port,
          host:  port[':host'],
          guest: port[':guest'],
          id:    port[':id']
      end

      config.vm.synced_folder "/bits", "/vagrant/bits"
      config.vm.synced_folder "../virtual", "/vagrant/virtual"

      config.vm.hostname = node_values[':hostname']
      #config.vm.network :private_network, ip: node_values[':ip']
      config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']

      config.vm.provider :virtualbox do |vb|
        vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
        vb.customize ["modifyvm", :id, "--name", node_values[':node']]
        vb.customize ["modifyvm", :id, "--cpus", 8]
      end

    end
  end
end

这是我的 nodes.json 文件的样子

{
  "nodes": {
    "virtual-am1": {
      ":node": "virtual-am1",
      ":ip": "192.168.1.50",
      ":hostname": "am1.onefederation.org",
      "ports": [
        {
          ":host": 2203,
          ":guest": 22,
          ":id": "ssh"
        }
      ],
      ":memory": 1024
    },
  }
}

请帮忙!!!

我遇到了这个错误,你可以使用这个修复:

删除vagrant中的文件夹项目

rm -rf /home/protobox/VirtualBox VMs/project_folder

转到项目文件夹:

cd /var/www/project_folder

然后重启vagrant:

vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload

你终于开始流浪了

vagrant up
vagrant ssh

或者您可以参考这里:http://getprotobox.com/docs/issues/vbox_rename

祝你好运!