Keeping your Homestead box Up-to-Date

As a Laravel developer, it is important that you always update your Laravel Homestead box to the latest release. This post is a simple guide on how.

Posted by Darwin Biler on January 30, 2016

Five days ago, a new version of Homestead (version 0.4.1) was released in VagrantCloud. When you vagrant up your machine, you might see messages like this:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: A newer version of the box 'laravel/homestead' is available! You currently
==> default: have version '0.4.0'. The latest is version '0.4.1'. Run
==> default: `vagrant box update` to update.

It is important that you keep the Homestead basebox installed in your local machine up to date, since this often contains latest versions of PHP, NodeJS and other toolset that you needed to take advantage of the newest Laravel features.

Downloading the latest version of Homestead

To update the version, assuming you had cloned the homestead repository on ~/Homestead folder. It is a very straight forward process:

cd ~/Homestead
vagrant box update

This will download the latest version of homestead

==> default: Checking for updates to 'laravel/homestead'
    default: Latest installed version: 0.4.0
    default: Version constraints: >= 0
    default: Provider: virtualbox
==> default: Updating 'laravel/homestead' with provider 'virtualbox' from version
==> default: '0.4.0' to '0.4.1'...
==> default: Loading metadata for box 'https://atlas.hashicorp.com/laravel/homestead'
==> default: Adding box 'laravel/homestead' (v0.4.1) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.4.1/providers/virtualbox.box
==> default: Successfully added box 'laravel/homestead' (v0.4.1) for 'virtualbox'!

Once the download completed, you will be able to see the latest version by issuing vagrant box list command:

vagrant box list
laravel/homestead (virtualbox, 0.4.0)
laravel/homestead (virtualbox, 0.4.1)

Updating your Homestead Machine

Note that after you had downloaded the latest version of Homestead, it doesn't automatically updates the virtual machine you are currently using. You have to destroy the currently running VM and re-provision it:

WARNING: all the databases and data inside your Homestead machine will all be gone, so make sure to export it before proceeding!
vagrant destroy

To rebuild your machine, you can issue vagrant up.

vagrant up

Purging old versions

You might want to delete the older base boxes as it may fill your disk space. To do so:

vagrant box remove laravel/homestead --box-version=0.4.0

And that's it, you are done!