Destroy Vagrant boxes properly

I’ve changed the root of the project twice since its beginning, so Vagrant kept some info in the cache about old boxes that were not there anymore.
In order to properly remove all boxes, if you want to “sanitize” from time to time your working folders, you should use:

vagrant global-status —-prune

This will remove all non-existing vagrant boxes from the cache.

Be aware that if you previously tried to destroy a non-existing box by its ID, and the task failed, it might not be possible to run the command specified above.
In this case, kill all the processes containing ruby or vagrant, and try the command again.

Also, in order not to be asked for confirmation for each box, you could use the “-f” parameter

vagrant destroy 1a2b3c4 -f

Note: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: