Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mattiman's avatar

Removing vagrant box

From a previous thread I learnt how to remove redundent (old) boxes https://laracasts.com/discuss/channels/general-discussion/delete-vagrant-box

However, trying to remove a vagrant box I get this message:

vagrant box remove laravel/homestead --box-version=0.2.2
Box 'laravel/homestead' (v0.2.2) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:

But the latest I have installed is 0.2.5.

  • Can't I remove the 0.2.2?
  • How do I know which one is being used by homestead?
  • And what is meant by "vagrant environment"?

Thanks for any help!

0 likes
16 replies
bashy's avatar

Sounds like it's still running or something.

Try

vagrant global-status
Mattiman's avatar

Thanks for your help! I ran your command and now get this:

$ vagrant box remove laravel/homestead --box-version=0.2.2
Box 'laravel/homestead' (v0.2.2) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:
default (ID: 9f059715835042ff9219f66fcb536e34)
Are you sure you want to remove this box? [y/N] N

$ vagrant global-status
id       name    provider   state   directory                                                 
----------------------------------------------------------------------------------------------
9f05971  default virtualbox running /Users/mattiman/.composer/vendor/laravel/homestead 
 
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"

So there's only one running right? Is it still running the older 0.2.2 version instead of the newer 0.2.5? Is there a way to find out?

bashy's avatar

It'll be on a git branch won't it? They go into the same directory so if you do this, you can list the branches and delete one if needed?

// list local branches
git branch

// delete branch
git branch -d name
bashy's avatar

Probably not, it only deletes the local branch. Not really something you could use to replace files in a remote git repo.

Mattiman's avatar

So it seems that Homestead is still using the 0.2.2 vagrant box, while there is a newer 0.2.5 box. How do I make Homestead switch?

Must say that at first Homestead seems easy, but the docs on laravel are really lacking in explaining how things work, how to troubleshoot problems or how updating everything works. There's this interdependency between Homestead, VirtualBox and Vagrant that makes searching for solutions in Google difficult, because most most answers are not related to Homestead specifically and are not working.

Mattiman's avatar

Have to bring this up again, because I still haven't found a solution.

When I run:

$ homestead halt
$ homestead update
==> default: Checking for updates to 'laravel/homestead'
    default: Latest installed version: 0.2.5
    default: Version constraints: 
    default: Provider: virtualbox
==> default: Box 'laravel/homestead' (v0.2.5) is running the latest version.

It says it's running the latest version. But if I try to remove the older one:

$ vagrant box remove laravel/homestead --box-version=0.2.2
Box 'laravel/homestead' (v0.2.2) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:

default (ID: 9f059715835042ff9219f66fcb536e34)

Are you sure you want to remove this box? [y/N]

How is it still being used? I'm afraid to say yes to that last answer, since it'll probably mess up everything.

Mattiman's avatar

Somebody should have an answer to this? How is everybody here managing their Homestead boxes? Updating and deleting old ones?

Nobody using it?

bashy's avatar

I think most just delete the files and start again.

Mattiman's avatar

Hi @bashy, which files? There are so many. There's

  • .composer folder with several folders related to homestead,
  • .homestead folder with several folders inside,
  • .vgrant_d folder with several boxes folders and lastly
  • VitualBox VMs folder with several homestead folders and files.
    Deleting everything and starting the whole process of getting everything installed is such a hassle. I can't do that every time I run into a problem with Homestead ... :(

Keeping homestead/vagrant/vitualbox running well and uptodate should be something everybody using it do on a weekly bases with just a few commands. But where's the documentation? It's so frustrating.

bashy's avatar

Well I don't personally use Homestead because it's a mess but...

.vagrant/
    Inside the .vagrant folder you will have a machines folder.
.homestead/
    Homestead files from GitHub repo?
~/VirtualBox VMs/
    VirtualBox VMs are stored in here, .vmdk is the files for it.

If you don't want to use Homestead, try a different one that's got the same capabilities but I find nicer to work with https://github.com/fideloper/Vaprobash

Mattiman's avatar

Ok thanks, if I don't find an answer I can look at vaprobash.

Too bad and strange that Homestead which is so prominently featured by/on Laravel and Laracasts (it's amazing! everybody should use it!) doesn't seem to get much attention.

bashy's avatar

Yeah, to do any problem solving with Vagrant/Homestead, you need to know a bit about how it works. Vaprobash isn't so "preset" as Homestead. Which is why I like it. You can also run Debian without many changes (few package edits). I also use it so I can install PHP 5.5/5.6 with a change of the config.

It is popular but most don't know how to fix problems like this one and it's really hard to help without working with the files/environment itself.

1 like
garethdaine's avatar

I know this is an old thread but doing the below should work:

  1. First destroy homestead. Make sure you backup your databases etc.
homestead destroy
  1. Next CD into your Homestead directory.
cd ~/.composer/vendor/laravel/homestead
  1. Remove the required box version.
vagrant box remove laravel/homestead --box-version=0.2.2
  1. Start homestead and provision
homestead up --provision

That should do it.

2 likes

Please or to participate in this conversation.