Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing list of vms in vagrant cache

Tags:

vagrant

I'm not looking for this answer, because my question is different.

When I type vagrant global-status I get a list of vms, but some of those directories and VMs have been deleted along with the Vagrantfiles.

But when i type vagrant destroy [machineid], I get the following error, which I am looking to resolve. Please advise.

The working directory for Vagrant doesn't exist! This is the specified working directory:  /Users/steven/projects/php/vagrant-laravel 
like image 441
user710587 Avatar asked Jun 26 '14 20:06

user710587


People also ask

How do I clear vagrant cache?

AFAIK, vagrant box remove just remove the boxes you downloaded or created using package command, to delete the VM, you should use `vagrant destroy` at the folder where Vagrantfile is. vagrant destroy will only delete the VM, so you still need to manually delete Vagrantfile and any other files in that folder.

How do I delete vagrant virtual machines?

Command: vagrant destroy [name|id] For linux-based guests, Vagrant uses the shutdown command to gracefully terminate the machine.

How do I delete all vagrant boxes?

Command: vagrant box remove NAME If a box has multiple versions, you can select what versions to delete with the --box-version flag or remove all versions with the --all flag.


2 Answers

You should use the following command to remove invalid entries from the global index:

vagrant global-status --prune 
like image 199
Emyl Avatar answered Sep 22 '22 13:09

Emyl


I had this issue as well. I was able to fix it by modifying the contents of ~/.vagrant.d/data/machine-index/index. It's in JSON format so I just removed the data related to instances that no longer existed.

I only removed the data that pertained to instances that no longer exist. I wouldn't modify any data that relates to an instance that exists in the file system.

like image 26
Sarcastron Avatar answered Sep 23 '22 13:09

Sarcastron