2

I've been trying to sync a folder between my computer and a Homestead VM run using Vagrant. My guess is that Vagrant isn't reading my Homestead.yaml file as no change is reflected in the VM.

I've tried the following:

  • Tried reloading, halting with provision after editing the file as mentioned here
  • Checked for tabs and ensured that there are 2 spaces in my yaml file
  • Rechecked the paths of the mounted folders. Tried variations like /home/abhirath/Desktop/Laravel_Recipes and ~/Desktop/Laravel_Recipes
  • Destroyed and recreated the VM
  • Read random tutorials like this
  • SSH'd into my VM. I don't see any folder there
  • I changed the memory from 2048 to 512 in the Homestead.yaml file and checked the RAM in my VM using sudo cat /proc/meminfo | grep MemTotal and it still shows 2048 MB
  • vagrant up with debug mode enabled. I couldn't find anything relevant in the debug logs

contents of ~/.homestead

  • after.sh
  • aliases
  • Homestead.yaml
  • Vagrantfile

Homestead.yaml

---
ip: "192.168.10.10"
memory: 512
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Desktop/Laravel_Recipes
      to: /home/vagrant/Laravel_Recipes

sites:
    - map: recipes.dev
      to: /home/vagrant/Laravel_Recipes/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp
halfer
  • 19,824
  • 17
  • 99
  • 186
Abhirath Mahipal
  • 938
  • 1
  • 10
  • 21

3 Answers3

2

Cause

I followed along the tutorial given on Laravel's Website like everyone else. I cloned their github repo to ~/Homestead like given in the tutorial. After running the bash script as mentioned the directory ~/.homestead came into existence. They mention running vagrant up while inside the .homestead directory. It needs the files present in the Homestead directory.

So the best solution would be to use
git clone https://github.com/laravel/homestead.git ~/.homestead
instead of
git clone https://github.com/laravel/homestead.git Homestead.

Explanation

Turned out I was using an almost empty Vagrantfile filled entirely with comments. Hence I wasn't using the Vagrantfile provided by Laravel. I used the default Vagrant file that came up after running vagrant init laravel/homestead

The plain Vagrantfile has almost zero settings. It doesn't look for any YAML or JSON file for user specified settings. Every change I made turned out to be useless due to this reason.

The vagrant file has to explicitly load the Homestead.yaml file in order to get the user settings. You can either edit the Vagrantfile (you need to know the basic of Ruby or tinker around) or just use the configured Vagrantfile that comes with Laravel.

The following articles helped me understand:

halfer
  • 19,824
  • 17
  • 99
  • 186
Abhirath Mahipal
  • 938
  • 1
  • 10
  • 21
  • Actually laravel doc clearly mention that once you cloned in the homestead repository you need to "run the `bash init.sh` command from the **Homestead** directory to create the `Homestead.yaml` configuration file" and "Once you have edited the Homestead.yaml to your liking, run the vagrant up command from your **Homestead** directory". Refer to "Installing Homestead" section and "Launching The Vagrant Box" section in the https://laravel.com/docs/5.3/homestead – Gayan Jan 05 '17 at 15:44
  • Thanks for the info. Will check that out as well :) – Abhirath Mahipal Jan 06 '17 at 02:05
  • 1
    I have copied whole file from: https://raw.githubusercontent.com/laravel/homestead/master/Vagrantfile and then it helps. – bumerang Jul 02 '18 at 14:57
1

When you do homestead up your existing configurations loaded from the Homestead.yaml file.

But if you change any if the existing configuration that won't be affected until you do homestead provision

Reference: Configure Homestead

Gayan
  • 3,614
  • 1
  • 27
  • 34
0

The problem is that the Vagrantfile created with init.sh during the aliases phase is trying to be written to .homestead If you have that directory it will be created and you can copy it to the ~/Homestead directory and vagrant will work properly. Otherwise you can copy the Vagrantfile from ~/Homestead/resources/localized to ~/Homestead