Can't run vagrant provision for Laravel Homestead Vagrant - laravel

I refer to Laravel's official documentation to install Homestead.
When I run the vagrant reload --provision , I get the error message shown below.
I found my mac .ssh directory, it is empty.
But Homestead.yaml includes this line authorize: ~ / .ssh / id_rsa.pub, I do not understand what is wrong.

I'm not sure, but I thought that keys where created when you add the homestead box to vagrant.
Anyway, the error says what the problem is. You don't have a ssh key so you need to create a new.
Enter your home directory (on your mac) and run this command:
ssh-keygen -t rsa -C "you#yourmail.com"
Then check directory: ~/.ssh/ so files are created and have the same name as referenced in Homestead.yaml

Related

ln: failed to create symbolic link: Protocol error (in Vagrant)

I'm using Laravel Homestead (Vagrant, Ubuntu). My host computer is Windows 10 running VirtualBox.
As admin (since I've already seen tons of answers that say lack of permissions is usually why people have problems with symlinks), I open Git Bash and run this:
vagrant#vboxHomestead:~/Code/myproject$ ls -lah /home/vagrant/foo/blah
total 0
drwxrwxrwx 1 vagrant vagrant 0 Mar 17 23:09 .
drwxrwxrwx 1 vagrant vagrant 0 Mar 17 22:36 ..
-rwxrwxrwx 1 vagrant vagrant 0 Mar 17 23:09 asdf.txt
vagrant#vboxHomestead:~/Code/myproject$ sudo ln -s /home/vagrant/foo/blah /home/vagrant/Code/myproject/storage/app/public/blah
ln: failed to create symbolic link '/home/vagrant/Code/myproject/storage/app/public/blah': Protocol error
What is the problem? Does it have something to do with the folder mappings of Homestead? How can I achieve my goal?
(My /home/vagrant/Code/ and /home/vagrant/foo/ map to separate drives on my Windows machine.)
P.S. And before trying the steps above, I even deleted the Homestead standard public symlink just to avoid other possible complications.
P.P.S. I've also tried adding this near the bottom (above the final end) of my Homestead Vagrantfile before spinning up the box:
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
I noticed that php artisan storage:link was now causing a "Protocol error" too.
So to narrow down the problem I created a totally fresh Homestead project and box and tried creating symlinks (including php artisan storage:link) in there but got the "Protocol error" too.
And I was very careful to be using Git Bash (my terminal / command line client) as Administrator, so I was already following the advice of most answers on StackExchange.
I also decided to move one of my Windows folders (the one that I'd had Homestead map to /home/vagrant/foo/) to be within the Windows folder that Homestead mapped to /home/vagrant/Code/.*
I decided to restart Windows 10 completely. Now after spinning up new vagrant boxes, php artisan storage:link and creating my other symlink worked.
*I'm not sure moving the Windows folder was even necessary. Maybe I could have left the folders on separate Windows drives. But at the time, I wanted to minimize possible complications.
When using Homestead, making a symlink in your public directory in Windows will also create a symlink on vagrant. The other way round may (!) create this error and will leave a not working symlink in your Windows directory.
The error sometimes return after you shutdown the VM and restart or still persists. Basically you need to again tell VirtualBox to enable symlinks. Here's the complete solution
Obviously have this in your vagrant file, as suggested above
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/Folder_Name", "1"]
end
I recommended comment out any sync folder and let default ./(at host) synced at /vagrant(at guest). This will make sure your shared folder(Folder_Name) name is always vagrant as mentioned here https://www.vagrantup.com/docs/synced-folders/. Also, you won't face issues with ssh
If the symlink protocol error returns after restart or still persists run
VBoxManage setextradata "VM_Name" VBoxInternal2/SharedFoldersEnableSymlinksCreate/Folder_Name 1
vagrant halt
vagrant up
vagrant ssh
Usually, VBoxManagee is located at C:\Program Files\Oracle\VirtualBox\
Verify working of symlink by going to /vagrant and running
touch test.txt && ln -s test.txt test1.txt
PS: I have tried this on Windows Home which has limited accessibility to security settings
Protocol error means that the language of communication between the folders is different. You musst have the same version of PHP. So you have to bring the PHP in the VM and on your Windows OS on the same version state.
Go like this:
update your PHP on you computer (i.e. download from php.org)
then open cmd as admin
cd homestead -> vagrant up -> cd code -> cd "your-APP"
sudo apt update -> sudo apt upgrade
ln -sr storage/app/public public/storage
and now there is no error and the folder puplic/storage has been created.
Good luck...

Vagrant command doesn't work without Sudo

I have installed homestead with Vagrant in my MacOS. I have installed all with Virtual Box, but when i try to use vagrant command in my terminal for running Virtual Machine appear this error:
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.
I try with sudo vagrant up and it work but is not the best choice.
Anyone can help me?
There's a screenshot of the terminal Error:
Terminal Error with command vagrant up and vagrant ssh.
Try deleting .vagrant directory
rm -r .vagrant
I suspect you copied or moved project folder from one place to another.
Alternatively you need to update the creator_uid file in .vagrant/. Check out this blog post.

How to update laravel/homestead?

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
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

Vagrant: "The box you're attempting to add already exists"

I am pretty new to Vagrant and already I seem to have hit a snag with it. I am basically following their get started guide.
When I type the command:
$ vagrant box add hashicorp/precise64
I get this error:
The box you're attempting to add already exists. Remove it before
adding it again or add it with the --force flag.
Name: hashicorp/precise64
Provider: virtualbox
Version: 1.1.0
Here is what I have tried.
I destroyed it first using:
$ vagrant destroy
I then backed out into documents using:
$ cd -
I then removed the director with:
$ rm -rf vagrant_getting_started
Then I created a new directory with:
$ mkdir vagrant_getting_started
I then went into that directory with:
$ cd vagrant_getting_started
Then I typed:
$ vagrant box add hashicorp/precise64
Which gave me:
==> box: Loading metadata for box 'hashicorp/precise64'
box: URL: https://vagrantcloud.com/hashicorp/precise64
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) hyperv
2) virtualbox
3) vmware_fusion
Enter your choice:
Finally I chose option 2 and then this is where the error is.
Can anyone see anything that I am doing wrong?
vagrant box remove -f laravel/homestead will remove the "laravel/homestead" from your machine and you can reinstall the same by vagrant box add laravel/homestead.
Unless the Vagrant box image has become corrupted, you don't need to download it again to re-use it.
Vagrant only downloads the boxes it doesn't have. Once a box image is saved locally on your system, Vagrant will use the local image to work from.
When setting up a new Vagrant based project, the following will happen:
You create or navigate to your project directory
Run vagrant init hashicorp/precise64. This will initialise Vagrant inside the directory, and create a new Vagrantfile if one doesn't exist. It also tells Vagrant which box image to use. If the box image is already stored locally - it won't download it.
Alternatively, if you already have a Vagrantfile in your project directory, simply run vagrant up. Vagrant will take care of everything for you - including downloading the box image (if applicable).

Vagrant - The host path of the shared folder is missing: ../keys

When I try to run vagrant up or vagrant provision I get this error:
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The host path of the shared folder is missing: ../../../../keys
I already tried vagrant destroy but I get the same error.
Does anybody have suggestions on what to check?
I'm on ubuntu 15.10
I've had this once before and there's plenty of possible solutions on the web.
What worked for me is to simply create the folder that's apparently missing. Do the following (easiest on command line):
cd /path/to/wherever/it/is/supposed/to/be/
mkdir keys
You should then be able to vagrant up fine.

Resources