hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.24k stars 4.44k forks source link

Destroy when directory is not found #5843

Closed zhdanovartur closed 9 years ago

zhdanovartur commented 9 years ago

I removed directory:

$ rm -rf /Users/zhdanovartur/Dev/test

then ran:

$ vagrant global-status
id       name    provider   state    directory                               
-----------------------------------------------------------------------------
5dd0eb0  default virtualbox running  /Users/zhdanovartur/Dev/test
...
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"

and

vagrant destroy 5dd0eb0

but there was an error:

The working directory for Vagrant doesn't exist! This is the
specified working directory:

/Users/zhdanovartur/Dev/test

It is true but vagrant global-status still returns same data. What about just remove row from cache if directory does not exists?

mbbroberg commented 9 years ago

+1 to this issue. I moved directories of a few vagrant projects and now global-status reports them at some previous state no matter what state they're in.

➜  vagrant-riak-cluster git:(master) vagrant global-status
id       name                                provider   state    directory
--------------------------------------------------------------------------------------------------------------------------
c384c3e  riak3                               virtualbox saved    /Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster
2448659  puppetlabs-centos-7.0-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
2689679  puppetlabs-centos-7.0-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
39716f6  puppetlabs-centos-7.0-64-puppet-3   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
f108ebf  puppetlabs-ubuntu-14.04-64-puppet-1 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
022d63d  puppetlabs-ubuntu-14.04-64-puppet-2 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
12a7b38  puppetlabs-ubuntu-14.04-64-puppet-3 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
c578038  puppetlabs-centos-6.6-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
30c5e91  puppetlabs-centos-6.6-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
f305d2a  puppetlabs-centos-6.6-64-puppet-3   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
51e2d58  puppetlabs-ubuntu-12.04-64-puppet-1 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
096988b  puppetlabs-ubuntu-12.04-64-puppet-2 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
82c6a27  puppetlabs-ubuntu-12.04-64-puppet-3 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
be48633  puppetlabs-debian-7.8-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
8503e1c  puppetlabs-debian-7.8-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
dbdf717  panamax-vm                          virtualbox poweroff /usr/local/Cellar/panamax/0.6.3/.panamax
ded1019  default                             virtualbox running  /Users/basho/Google Drive/Basho-Dev/riak-vagrant

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"
➜  vagrant-riak-cluster git:(master) vagrant destroy c384c3e
==> riak3: VM not created. Moving on...
==> riak3: Removing hosts
==> riak3: No machine id, nothing removed from /etc/hosts
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:4: warning: already initialized constant CENTOS
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:4: warning: previous definition of CENTOS was here
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:8: warning: already initialized constant UBUNTU
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:8: warning: previous definition of UBUNTU was here
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:13: warning: already initialized constant NODES
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:13: warning: previous definition of NODES was here
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:14: warning: already initialized constant OS
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:14: warning: previous definition of OS was here
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:15: warning: already initialized constant BASE_IP
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:15: warning: previous definition of BASE_IP was here
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:16: warning: already initialized constant IP_INCREMENT
/Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster/Vagrantfile:16: warning: previous definition of IP_INCREMENT was here
➜  vagrant-riak-cluster git:(master) vagrant global-status
id       name                                provider   state    directory
--------------------------------------------------------------------------------------------------------------------------
c384c3e  riak3                               virtualbox saved    /Users/basho/Google Drive/Basho-Dev/vagrant-riak-cluster
2448659  puppetlabs-centos-7.0-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
2689679  puppetlabs-centos-7.0-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
39716f6  puppetlabs-centos-7.0-64-puppet-3   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
f108ebf  puppetlabs-ubuntu-14.04-64-puppet-1 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
022d63d  puppetlabs-ubuntu-14.04-64-puppet-2 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
12a7b38  puppetlabs-ubuntu-14.04-64-puppet-3 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
c578038  puppetlabs-centos-6.6-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
30c5e91  puppetlabs-centos-6.6-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
f305d2a  puppetlabs-centos-6.6-64-puppet-3   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
51e2d58  puppetlabs-ubuntu-12.04-64-puppet-1 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
096988b  puppetlabs-ubuntu-12.04-64-puppet-2 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
82c6a27  puppetlabs-ubuntu-12.04-64-puppet-3 virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
be48633  puppetlabs-debian-7.8-64-puppet-1   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
8503e1c  puppetlabs-debian-7.8-64-puppet-2   virtualbox saved    /Users/basho/Desktop/Google Drive/Basho-Dev/puppet-riak
dbdf717  panamax-vm                          virtualbox poweroff /usr/local/Cellar/panamax/0.6.3/.panamax
ded1019  default                             virtualbox running  /Users/basho/Google Drive/Basho-Dev/riak-vagrant
➜  riak-2.1.0  cd $WORK/puppet-riak
➜  puppet-riak git:(add-maintainers) ✗ vagrant status
Current machine states:

puppetlabs-centos-7.0-64-puppet-1   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-2   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-3 not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-1   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-2   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-3 not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-1   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-2   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-3   not created (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
➜  puppet-riak git:(add-maintainers) ✗ vagrant destroy
==> puppetlabs-debian-7.8-64-puppet-3: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-3: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-debian-7.8-64-puppet-2: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-2: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-debian-7.8-64-puppet-1: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-1: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-3: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-3: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-2: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-2: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-1: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-1: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-3: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-3: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-2: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-2: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-1: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-1: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-3: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-3: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-2: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-2: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-1: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-1: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-3: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-3: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-2: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-2: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-1: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-1: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-1: No machine id, nothing removed from /etc/hosts
➜  puppet-riak git:(add-maintainers) ✗ vagrant status
Current machine states:

puppetlabs-centos-7.0-64-puppet-1   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-2   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-3 not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-1   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-2   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-3 not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-1   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-2   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-3   not created (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
➜  puppet-riak git:(add-maintainers) ✗ vagrant destroy
==> puppetlabs-debian-7.8-64-puppet-3: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-3: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-debian-7.8-64-puppet-2: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-2: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-debian-7.8-64-puppet-1: VM not created. Moving on...
==> puppetlabs-debian-7.8-64-puppet-1: Removing hosts
==> puppetlabs-debian-7.8-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-3: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-3: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-2: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-2: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-12.04-64-puppet-1: VM not created. Moving on...
==> puppetlabs-ubuntu-12.04-64-puppet-1: Removing hosts
==> puppetlabs-ubuntu-12.04-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-3: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-3: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-2: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-2: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-6.6-64-puppet-1: VM not created. Moving on...
==> puppetlabs-centos-6.6-64-puppet-1: Removing hosts
==> puppetlabs-centos-6.6-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-3: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-3: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-2: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-2: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-ubuntu-14.04-64-puppet-1: VM not created. Moving on...
==> puppetlabs-ubuntu-14.04-64-puppet-1: Removing hosts
==> puppetlabs-ubuntu-14.04-64-puppet-1: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-3: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-3: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-3: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-2: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-2: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-2: No machine id, nothing removed from /etc/hosts
==> puppetlabs-centos-7.0-64-puppet-1: VM not created. Moving on...
==> puppetlabs-centos-7.0-64-puppet-1: Removing hosts
==> puppetlabs-centos-7.0-64-puppet-1: No machine id, nothing removed from /etc/hosts
➜  puppet-riak git:(add-maintainers) ✗ vagrant status
Current machine states:

puppetlabs-centos-7.0-64-puppet-1   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-2   not created (virtualbox)
puppetlabs-centos-7.0-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-14.04-64-puppet-3 not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-1   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-2   not created (virtualbox)
puppetlabs-centos-6.6-64-puppet-3   not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-1 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-2 not created (virtualbox)
puppetlabs-ubuntu-12.04-64-puppet-3 not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-1   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-2   not created (virtualbox)
puppetlabs-debian-7.8-64-puppet-3   not created (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
➜  puppet-riak git:(add-maintainers) ✗ pwd
/Users/basho/Google Drive/Basho-Dev/puppet-riak

Note a secondary problem (that I'm not sure whether it's expected) that all VMs are listed as not created when I anticipated they wouldn't show up in the local status.

sethvargo commented 9 years ago

@zhdanovartur

What happens if you run vagrant global-status --prune?

zhdanovartur commented 9 years ago

Sorry, I don't know how it happened :)

mbbroberg commented 9 years ago

Oh nice! The --prune did the trick for me @sethvargo.

AlopexID commented 6 years ago

Thank you for the prune trick

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.