How to update laravel/homestead?

Viewed 10599

I need to update laravel/homestead? It is a Vagrant box. I'm using it for my dev environment.

I remember it was a shell command but I don't remember the command and I cannot find it. Please help

6 Answers

This is the sequence I came up with recently (Apr 2020) to upgrade my vagrant box from 9.2.x to 9.5.x

If the VM is not running first do:

vagrant up

Then go into the VM:

vagrant ssh

and back up the databases:

mysqldump -u homestead --all-databases -p > homestead-backup.sql

copy the resulting file to the host machine (only if the above command was not run in a mapped folder)

Close the ssh connection:

exit

then run:

vagrant box update
vagrant destroy
vagrant box prune

Answer yes to all questions. Then

git fetch
git pull origin release

Start the VM again:

vagrant up

once it's started (it will take longer this time) go into the VM:

vagrant ssh

and restore the databases (copy the backup file over from the host if it was not in the mapped folder)

mysql -u homestead -p < homestead-backup.sql

Note: add -p if needed to mysql import and export, it will prompt for password (default: "secret")

Use below command

homestead update

If this doesn't work

homestead box update

If this also doesn't work at all

This command will tell you the state of all active Vagrant environments on the system for the currently logged in user.

vagrant global-status

vagrant box update "laravel/homestead"

I hope i am clear now!

First update your box:

vagrant box update

And, as it is documented here:

https://laravel.com/docs/master/homestead#updating-homestead

You should first destroy the machine and recreate it:

vagrant destroy
vagrant up

Just tested and it worked for me. (updated from homestead: '8.2.0' to '9.0.0')

Do not forget to backup your existing database datas before destroying the machine.

Please follow this url which will guide you to update the laravel/homestead

Update laravel homestead

also the basic steps is cd into your homestead directory and run vagrant box update it will download the latest version

If you used a default settings on installation, you need

1) go to your vagrant folder

$ cd ~/Homestead/

2) run vagrant box update command

$ vagrant box update "homestead-7"

Tested on Laravel 5.6/5.7

First, check the available homestead releases:
https://github.com/laravel/homestead/releases

To check your homestead and vagrant versions use these commands:

  • for the Vagrant version:

vagrant version

I had Installed Version: 2.2.10, the last version for mac was 2.2.14

  • for the Homestead version, go to the folder ~\Homestead and:

git branch -v

In my case, I had this output: HEAD detached at v11.4.0

Then, how to update Vagrant and Homestead?
First, make sure you backup the DB!
https://laravel.com/docs/8.x/homestead#database-backups

In my case, the automatic backup didn't work, and the first time I did the vagrant destroy I lost the DBs, so I suggest to backup manually like this:

vagrant ssh
mysqldump -u homestead -p --all-databases > homestead-20210214.sql

Then copy file out from the Vagrant machine before destroying: from ~/Homestead 

scp -P 2222 vagrant@127.0.0.1:/home/vagrant/homestead-20210214.sql .

Then from the Homestead directory:

vagrant destroy
git fetch

To check the version of your homestead:

vagrant box list

In my case, I had:
laravel/homestead (virtualbox, 10.1.1)

Here you can check the latest stable release of Homestead:
https://github.com/laravel/homestead/releases.
In my case was Homestead 12.

But actually what you are going to install is the latest stable release of the laravel/homestead Vagrant box. You can see the latest release here.
https://app.vagrantup.com/laravel/boxes/homestead.
In my case was v11.0.0

Then since in my case, the latest Homestead was v12.0.0 I did:

git checkout v12.0.0
vagrant box update
bash init.sh
vagrant up

And you are done.
Then you can restore the DBs.

How if I run

vagrant box list

I see:
laravel/homestead (virtualbox, 11.0.0)

Have a look also at the official documentation here. https://laravel.com/docs/8.x/homestead#updating-homestead

Related