Laravel Homestead: Adding an additional virtual machine using vagrant box - laravel-4

There has been a recent change lately when attempting to clone the laravel/homestead package from GitHub. I haven't had trouble in the past trying to add additional virtual machines to my system but now I'm running into a problem.
If you go into GitHub to look at the latest repository for Laravel Homestead you will see that the 'homestead.yaml' file is not in the root directory any longer and has now been replaced by the file 'homestead'.
In the past, I have used the steps below for creating additional virtual machines in my command prompt:
1) Create a new directory (Code2) from within the root directory where VirtualBox and VagrantBox are installed
2) Go into 'cmd' and change to 'Code2' directory
3) Type in 'vagrant box add laravel/homestead --force'
4) Type in 'git clone https://github.com/laravel/homestead.git Homestead_temp'
5) Go into the newly created 'Homestead_temp' directory, copy and paste the files from inside that directory into your 'Code2' root directory.
6) Edit 'src/stubs/homestead.yaml' so that it contains the correct paths for your 'Code2' directory.
7) Go back into 'cmd' and type in 'vagrant up'. When I try to do this, I keep getting a 'read: No such file or directory C:/Users/Jeff/.homestead/Homestead.yaml'
I haven't had trouble in the past adding additional virtual machines but now I am prevented from doing so. Any help is greatly appreciated.

I'm not really sure if this answers my question or not, I'll have to do some research on it but for anybody that is curious about the recent Laravel Homestead changes, check out this article for Laravel 2.0
Hope this information helps!

Related

How to destroy and recreate vagrant/homestead machine?

I'm running Laravel on Vagrant Box (homestead)
When I'm doing vagrant up, I'm getting a message:
: A newer version of the box 'laravel/homestead' is available and already
: installed, but your Vagrant machine is running against
: version '6.3.0'. To update to version '7.1.0',
: destroy and recreate your machine.
What commands should I run and what are potential problems I should be prepared for?
You can create a second installation for Homestead before you destroy the working one.
1) follow official documentation on installing Installing The Homestead Vagrant Box, then, when Installing Homestead instead of this command
git clone https://github.com/laravel/homestead.git ~/Homestead
run this one
git clone https://github.com/laravel/homestead.git ~/MyHomestead
then you'll need to cd ~/MyHomestead and git checkout v8.4.0
now you need to go to ~\MyHomestead\scripts\homestead.rb file and replace homestead-7 to homestead-7-my it will give you a different name for virtual machine in your virtualbox.
Now you can follow the official documentation
1.1) and you can always destroy your old vagrant box from your vagrant folder usually ~/homestead by running
vagrant destroy
2) create a new vagrant box by running
vagrant up --provision
3) get in to vagrant
vagrant ssh
4) go to your project (I assume you have a set of database migrations and seeders )
cd ~/code/myproject
4.1) you'll find redis and mysql is working there already.
5) create database
php artisan migrate
6) make SUPERVISOR works if you need it
7) make cron work if you need it
Done
As ceejayoz mentioned, you do not have to do this, you can just continue running the same version. Homestead is meant to be able to be torn down / built back up quickly, with all configuration living within the Homestead.yaml and Vagrantfile files. It's supposed to be able to do the heavy lifting for you with those config files.
As you mentioned, you have your database in Homestead. If you have some data there that is not local test data, ensure you get that exported before destroying. Some people manually modify their Homestead VM via SSH which is not recommended (as you should be using the Homestead.yaml file for changes), but if you have, keep a list of the changes you made and where you made them.
Here is a rundown of things you may want to keep before destroying:
Your Homestead.yaml file, just in case
Your Vagrantfile file(s) (if you've made custom changes)
Database data
Files used / generated by your application (logs, for instance.)
aliases file, if you've made custom changes to it
Elasticsearch data (if you use it)
Neo4j data (if you use it)
As for commands to run, the documentation says it better than I ever could: https://laravel.com/docs/5.7/homestead#updating-homestead

Vagrant - Bash: Command not found

Looking for some assistance with Vagrant, for what I believe is a Server Variable issue.
I have been trying all weekend to get any kind of Vagrant install up and running. I have followed:
Laravel Homestead installation guide, and
Sitepoint Homestead Vagrant VM guide.
I am using the default folders for install. Whatever I do, after installing Vagrant, I am unable to run 'vagrant up' or vagrant init' because the command 'vagrant' cannot be found (bash: vagrant: command not found). I am trying to execute from the folder with Vagrantfile in it, as suggested by Sitepoint.
I found this Stack Overflow article: Vagrant Command Stopped Working: Command not Found on Windows, but with the current version doesn't work as that bin folder is empty (note that the 'embedded' folder beside it is full, with several 'bin' folders down within the subfolder structure).
I am not familiar enough with Vagrant to know to which folder I should set the server variable, if indeed that is the right answer. It has to be simple, as no sites address this particular issue anywhere. Any assistance will be greatly appreciated.
Win 7, Vagrant 2.1.2, Virtualbox 5.2.14
At the time of writing, Vagrant v2.1.2 is missing vagrant.exe in the i686.msi file.
There are two parts to this answer.
In GitBash, run commands with .\ preceeding the filename(ie .\vagrant up). See earlier comments for the credit for this answer.
Missing executable has been raised as an issue on Github. Without the executable, it, of course, was throwing a command not found error. https://github.com/hashicorp/vagrant/issues/10026?_pjax=%23js-repo-pjax-container
Thanks for your support Rohit.

Laravel Homestead vagrant up box issue

I am installing laravel homestead. As I am new on this so maybe i took some steps wrong while installing and setting up laravel homestead on windows.
I followed a tutorial and download laravel homestead box directly and then install it manually by giving it a local disk url. It installed perfectly fine till then. But now when i am trying to "vagrant up" command it says that box doesnt found.
So after that I read somewhere that it we have to add manyual metadata somewhere but I dont know where. And after some changes I am facing this error.
Once you have downloaded the box manually, you need to add it to vagrant config, so vagrant knows about the box for later user. run the following command :
$ vagrant box add --box-version <VERSION_DOWNLOADED> laravel/homestead <path to downloaded file>
After this, make sure to go to the folder where homestead has been cloned (do not do that from the .vagrant directory, just go somewhere else, and avoid path with space, windows generally does not like it; C:\homestead will be just fine for a test) and you can run vagrant up from there

Issue with setting up Vagrant

I have just set up a new Linux box and trying to install vagrant on it. The issue is that when I am running vagrant up command, I am getting the following error:
Vagrant failed to initialize at a very early stage:
The directory Vagrant will use to store local environment-specific
state is not accessible. The directory specified as the local data
directory must be both readable and writable for the user that is
running Vagrant.
Any idea how to fix this?
I think a better way is to provide your user the required permission to the directory by making the user the owner - where you want the vagrant to be booted:
$ sudo chown -R <user> <directory>
and then you will be easily able to do:
$ vagrant up
Using sudo for vagrant up is unusual as why do you want to run your virtual machine as a root user.
I met the same problem and I solved it by run the terminal with"run as administrator". It's quite easy.
Hope this can help you.
I encountered the same issue four years later and could not fix it using chmod or even #Ziya's comment under the initial question (which brought me closer to the resolution though).
In my case, I use Vagrant 2.2.6 on Windows 10, and use Cygwin as a command line interface.
For the error to disappear, I had to :
open Windows Explorer
right-click .vagrant folder in the location where I typed vagrant up
access the "Properties" menu
then, in the "Security" tab, update the authorizations for my user, granting total control
Properties window screenshot
Hope this can help someone else.
Please follow these steps:
1) install vagrant 1.7.1
2) install virtual box 4.1, 4.2, or 4.3
3) use the administrator name in the custom directory (e.g., for windows users c:\users\AdminName\myvagrant or for Mac/Linux users /home/Admin/myvagrant)
For instance: c:\users\safwan\myvagrant where safwan is the user with administrator rights/privileges.
Copy the file name Vagrantfile in the myvagrant forlder.
4) Now open DOS window as shown in the picture and follow the steps in the DOS window changing the admin name

Vagrant: how to edit files on the Vagrant server?

I'm following these instructions for setting up a Django app on Vagrant.
I have successfully completed them and started Django, but: how can I now edit the Django files within my usual text editor, TextMate?
I guess I can ssh and use vi to edit them from the command line, but I thought the point of Vagrant was to be able to use my usual editing tools.
I'm just not sure where the Django files are physically located.
Apologies if this question is off-topic, I'll happily post it elsewhere, if editors can let me know where is best.
That web site is exactly the same place I started a few months ago.
Since I've learned more about Vagrant since then, I've created my own GitHub repo. You can download it here:
https://github.com/FlipperPA/djangovagrant
The way it is setup:
git clone the repo to a local directory on your machine
cd into that directory
run "vagrant up"
the directory you run "vagrant up" in is mapped to /vagrant on the guest virtual machine
Here is a working example of the way one might do it:
cd $home
git clone https://github.com/FlipperPA/djangovagrant.git
cd djangovagrant
vagrant up
vagrant ssh djangovm
cd /vagrant
django-admin.py startproject django_project
cd django_project
python manage.py runserver [::]:8000
You will then see the Django Project build on your local machine in the "djangovagrant" folder you created by the clone command above. You can you Textmate, Sublime, or any text editor you like to edit the files locally, and they'll be mapped to the guest VM.
I hope this helps - good luck.
Vagrant always synchronizes the files in the project you set up with your PC.
So whenever you ssh into the vagrant, (usually) in /vagrant directory you can see all the files you have in the root folder of your project (directory where Vagrantfile ruby script is)
Now you can use your text editor and save the file in a folder you want (for convenience, always save new files inside the project directory). now mirroring your directory structure around the /vagrant directory you can see the file being saved in the appropriate folder in your guest machine.
For e.g if you created and saved a file in your project root folder then you can see it appear in /vagrant directory.

Resources