46

I have updated a box vagrant box update and now when I run vagrant up it boots into the old box. How can I update my box to use the newer version?

jaynp
  • 3,275
  • 4
  • 30
  • 43
Steven
  • 13,250
  • 33
  • 95
  • 147

2 Answers2

61

From the Vagrant docs:

Finally, you can update boxes with vagrant box update. This will download and install the new box. This will not magically update running Vagrant environments. If a Vagrant environment is already running, you'll have to destroy and recreate it to acquire the new updates in the box. The update command just downloads these updates locally.

Reezy
  • 984
  • 1
  • 9
  • 12
  • 17
    So I need to run `vagrant destroy` and then `vagrant up` ? – Steven Sep 18 '14 at 13:47
  • 1
    `vagrant reload` The equivalent of running a halt followed by an up. – Joe Sep 18 '14 at 19:19
  • 21
    reload wont do it.. you need destroy – Joel Oct 10 '15 at 02:51
  • 1
    Can I run `vagrant box update` in parallel when I already have a machine running? http://stackoverflow.com/questions/42721065/can-i-use-vagrant-box-update-while-already-having-the-machine-running-by-vagr – giovannipds Mar 10 '17 at 14:49
  • 3
    I had to run `vagrant box remove laravel/homestead --box-version 1.1.0` so that `vagrant up` would then run the 4.0 version. – Ryan Nov 04 '17 at 00:27
  • @Joe based on `vagrant box update -h` > Updates the box that is in use in the current Vagrant environment, if there any updates available. This does not destroy/recreate the machine, so you'll have to do that to see changes. Looks like we will need to destroy and up again. – GusDeCooL May 17 '19 at 02:21
  • To finally answer @Steven 's question: In my case yes. I ran `vagrant destroy` after looking up how to update the box without doing anything b4 that. `vagrant box update` did **not** work after that, it said the new box was not downloaded and it could not update to it. So I just ran `vagran up` and it downloaded the new box and provisioned it from scratch as expected. – redanimalwar Nov 09 '20 at 23:07
  • To update a specific box you can use the `--box` argument. For example `vagrant box update --box archlinux/archlinux`. – Gonçalo Ribeiro Jan 10 '22 at 12:59
0

After a vagrant box update the system will have (at least) two boxes. You can see what's downloaded with vagrant box list.

To remove the old one(s) and use the new you can either do vagrant box remove laravel/homestead --box-version x.y.z as @Ryan said or issue a vagrant box prune command.

You'll be told

Removing the box could corrupt the environment. We recommend destroying these environments first:

homestead (ID: [...some string...])

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

Destroying a box will remove all the databases and other changes you've made, so be sure you've backed that up. Your Code directory is on your 'real' computer so is safe. (Tip: create a cron job to back up your databases to your Code directory, or use Homestead's automatic database backup on destroy

In practice I rarely have to destroy a box so after removing the old box can issue a vagrant up or vagrant reload --provision command and get back to work.

liamvictor
  • 3,251
  • 1
  • 22
  • 25