vagrant up is not starting the vm in .vagrant\machines\default\virtualbox\id

Tag: vagrant Author: suzuki9112 Date: 2013-06-25

When I run vagrant up, a new virtualbox machine is created rather than running the virtualmachine identified in .vagrant\machines\default\virtualbox\id. The id of the new virtual machine is then written to the id file.

My VMs:

C:\Users\Chris>vboxmanage  list vms
"MyVM_1373377014" {177aef6c-b9ec-4a85-adad-76c70f80fa62}

Next:

C:\Users\Chris>echo 177aef6c-b9ec-4a85-adad-76c70f80fa62 > .vagrant\machines\default\virtualbox\id

Followed by:

C:\Users\Chris>vagrant up

Results in a new VM:

C:\Users\Chris>vboxmanage  list vms
"MyVM_1373377014" {177aef6c-b9ec-4a85-adad-76c70f80fa62}
"MyVM_1373566342" {4fedb342-cc0b-40fd-a8d1-403049065274}

And the id containing the new VM id:

C:\Users\Chris>type .vagrant\machines\default\virtualbox\id
4fedb342-cc0b-40fd-a8d1-403049065274

So a new VM is created for some reason rather than starting the existing one.

I'm running Vagrant version 1.2.3

Best Answer

Make sure a newline isn't added to the ID. Therefore, instead of this:

echo "177aef6c-b9ec-4a85-adad-76c70f80fa62" > .vagrant/machines/default/virtualbox/id

I had to do this:

echo -n "177aef6c-b9ec-4a85-adad-76c70f80fa62" > .vagrant/machines/default/virtualbox/id

Note the -n switch to the echo command.

Sources: