Unable to clean up a VM after deleting a project file

1,033 views
Skip to first unread message

Yaniv Ben Yosef

unread,
Oct 2, 2014, 2:26:00 PM10/2/14
to vagra...@googlegroups.com
Hi,

I deleted a project directory that had a Vagrant file with single VM. Unfortunately, that VM was still running when I deleted the environment. The deletion included the Vagrantfile and the .vagrant directory.
Then when I executed vagrant global-status, I got the following output:

id       name    provider   state    directory                                
------------------------------------------------------------------------------
c88547e  default virtualbox poweroff /Users/yaniv/IdeaProjects/auxlinux-integ  
3a4c20f  host0   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
9243526  host1   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
bc31c93  host2   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
3ed6252  default virtualbox running  /Users/yaniv/dev/mi/mi-saf                
a3b2d05  default virtualbox poweroff /Users/yaniv/dev/scala-e2e-testing      

When changed the directory to /Users/yaniv/dev/mi/mi-saf, and executed vagrant destroy 3ed6252, I got the following message:

21:04 $ vagrant destroy 3ed6252
==> default: VM not created. Moving on...

After that, I opened VirtualBox, and removed the vm manually via the UI. However, vagrant still returns the following list:

id       name    provider   state    directory                                ------------------------------------------------------------------------------
c88547e  default virtualbox poweroff /Users/yaniv/IdeaProjects/auxlinux-integ 
3a4c20f  host0   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
9243526  host1   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
bc31c93  host2   virtualbox aborted  /Users/yaniv/dev/ansible-tuto            
3ed6252  default virtualbox running  /Users/yaniv/dev/mi/mi-saf               
a3b2d05  default virtualbox poweroff /Users/yaniv/dev/scala-e2e-testing       

Any idea how I can tell Vagrant to remove this VM?


Thanks,
Yaniv

Seth Vargo

unread,
Oct 2, 2014, 2:46:43 PM10/2/14
to vagra...@googlegroups.com
Hey Yaniv,

This can be a bit confusing, and it looks like other people have had this issue before: http://stackoverflow.com/questions/24440142/removing-list-of-vms-in-vagrant-cache. The cache is just that (a cache). You can prune the cache like this:

    vagrant global-status --prune

Hope that helps!

- Seth

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yaniv Ben Yosef

unread,
Oct 2, 2014, 3:02:21 PM10/2/14
to vagra...@googlegroups.com
Thanks Seth! I was sure I wasn't the first one to come across this problem, and I did search for it, but didn't find the answer you pointed out.
Anyway, your solution worked great for me. 
As a note to the Vagrant developers:
1. please add this to the documentation
2. more importantly, please add the --prune to the command line help printout

Thank you!
Yaniv

Seth Vargo

unread,
Oct 2, 2014, 4:23:38 PM10/2/14
to vagra...@googlegroups.com, Yaniv Ben Yosef
Hey Yaniv,

The vagrant docs actually have the following paragraph on: https://docs.vagrantup.com/v2/cli/global-status.html

> This command doesn't actively verify the state of the machines listed, and is instead based on a cache. Because of this, it is possible to see stale results (machines say they're running but they're not). For example, if you restart your computer, Vagrant wouldn't know. To prune the invalid entries, run global status with the --prune flag.

And it shows in my help output. Try upgrading your vagrant version? 

I'm glad we figured it out though!

- Seth
Reply all
Reply to author
Forward
0 new messages