Florian Shena
Florian Shena

Reputation: 1434

Laravel Homestead folders mapping not working correctly

I have installed homestead following the steps described in the Laravel site. The installation is completed successfully.

I have configured the Homestead.yaml file:

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

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: D:/Code/Homestead/Projects/RestaurantManager
      to: /home/vagrant/RestaurantManager

sites:
    - map: laravel.app
      to: /home/vagrant/RestaurantManager/public

databases:
    - homestead

variables:
    - key: 'APP_ENV'
      value: 'local'
    - key: 'APP_DEBUG'
      value: 'true'

Edit the hosts file:

127.0.0.1   laravel.app
192.168.10.10 laravel.app

I can run vagrant up and ssh into the virtual machine.

The problem is that the folder mapping does not work. The mapping always uses the same path (D:/Code/Homestead), despite me giving a different one. You can see it here:

enter image description here

So when I try to access the app locally I get "page not available".

Upvotes: 6

Views: 6372

Answers (5)

Marius Crisan
Marius Crisan

Reputation: 11

First of all, you need to know that Vagrant automatically configures the current directory of the Vagrantfile from the host machine as a shared folder to the /vagrant directory inside the VM.

To disable this default behaviour, add this line in your Vagrantfile:

config.vm.synced_folder ".", "/vagrant", disabled: true

Secondly, you can write the windows file path by escaping the \ characters like so:

folders:
    - map: D:\\Code\\Homestead\\Projects\\RestaurantManager
      to: /home/vagrant/RestaurantManager

⚠Important: After you've done this, run:

vagrant reload --provision

Alternatively, you can delete the whole folders section in your Homestead.yaml and specify the shared folders mapping directly in Vagrantfile like so:

config.vm.synced_folder ".", "/home/vagrant/RestaurantManager"

Upvotes: 1

Jesús Amieiro
Jesús Amieiro

Reputation: 2483

I have a similar problem due to the vagrant-hostsupdater. Just uninstall the plugin using

vagrant plugin uninstall vagrant-hostsupdater

and then provision the machine again

vagrant reload --provision

Upvotes: 1

teeyo
teeyo

Reputation: 3755

The golden rule when you change something in the configuration is to reload the vagrant machine with the provision option, so try running :

vagrant reload --provision

Upvotes: 9

Kirk Beard
Kirk Beard

Reputation: 9843

The Homestead.yaml file should have:

folders:
    - map: D:/Code/Homestead/Projects # Note 1
      to: /home/vagrant/Code # Note 2

sites:
    - map: laravel.app
      to: /home/vagrant/Code/RestaurantManager/public
  1. Should match your OS file structure
  2. The file structure of Homestead, which you should not change.

Your hosts file also needs to be updated to remove the reference to 127.0.0.1 (which is your localhost):

192.168.10.10 laravel.app

Upvotes: 1

Pistachio
Pistachio

Reputation: 1652

For windows use the backslash \ when mapping to a specific folder Try this:

folders:
    - map: D:\Code\Homestead\Projects\RestaurantManager
      to: /home/vagrant/RestaurantManager

Upvotes: 0

Related Questions