Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDan Donche
6,214 PointsVagrant: The host path of the shared folder is missing
I've seen a lot of people have this problem, but posting "me too" to the other questions never seems to result in any progress. So here I am, except I'm going to restate the question in a different manner. For others who have the question, I will attempt to explain WHY we are mapping the locations in the first place, because 90% of my problem initially came from not understanding what we were trying to accomplish.
First things first. I have installed Virtual Box and Vagrant, installed Homestead and even managed to get a new Laravel project started. The problem arises when I go in to edit the homestead.yaml file. There is a step in the process before you "vagrant up" when you edit the yaml file to connect the directory of your project with vagrant. Basically the idea is since we are going to be running the project on a virtual environment, it makes it so you can edit your project files separately and Vagrant will see the changes. I think of it like how Dropbox works. So the idea is simple: tell the system which directory from Vagrant you want to be synced with your project.
When I run the "vagrant up" command in git bash (I'm on Windows), I get the following error: the host path of the shared folder is missing /c/users/student/homestead/code
This is the windows directory where my laravel code lies. I have it mapped to sync up with the directory in vagrant (/c/vagrant/code). Typically this problem arises from the directory not being there. In other words, it would mean in my case that there is no directory inside homestead called "code".
Except I have both directories. So I don't understand what is wrong. Here is my yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /c/Users/Student/homestead/Code
to: /c/Vagrant/Code
sites:
- map: laravel.dev
to: /c/Users/Student/homestead/Code/laravel-test/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
2 Answers
thomascawthorn
22,986 PointsYou'll find that there are loads of situations where the core instructions don't work for you - especially with the wide variety of dependencies and operating systems. The great thing is, as you've discovered, there's always a fix somewhere on the internet!
Xampp will work for you, but the huge benefit of installing a 'box' of any description is that it holds all the dependencies in a controlled environment instead of your base operating system. I only found real benefit to this a little further down the road, but when I realised how useful it was, I wish I'd done it sooner because my mac is now riddled with hacks here and there.
Say for example you have two live servers running with very different setups / php versions / dependencies, you'll probably need to match those environments locally when coding. This becomes super easy when you can change that environment at the flick of a switch.
Laragon looks pretty cool and from the website appears to offer pretty similar things, so awesome!
To look on the brightside, after all this searching you must have learned a hell of a lot about vagrant, local environments, server stuff - that's incredibly useful to know!!
ps a nice little test to make sure your folders and files are where you think they are is by trying to navigation to that directory in the terminal.
cd /c/Users/Student/homestead/Code/laravel-test/public
Did you try an alternative ip address: "10.0.10.10"?
Also it looks like you're mapping to your windows machine, not the box.. maybe.
- map: laravel.dev
to: /c/Users/Student/homestead/Code/laravel-test/public
should be
- map: laravel.dev
to: /c/Vagrant/Code/laravel-test/public
(I'm only comparing my setup to yours, but I'm unfamiliar with windows)
This might've been causing your error: the host path of the shared folder is missing /c/users/student/homestead/code
laravel.dev:8000 will be pointing to 'the box', and this line gives the location of your code inside 'the box' - not on your machine. It's likely to be complaining because the directories you've specified don't exist within 'the box', they're in your central operating system.
Hope this helps!
Dan Donche
6,214 PointsI wouldn't even sweat trying to figure this out. I have been trying to get Laravel to work on my Windows machine for over 24 hours already now every hour added decreases my excitement about trying this thing out. I managed to get Laravel to work in about ten minutes with Xampp. So to anyone asking "why not use Homestead?" This is precisely why. Super huge thanks to the guy who created Laragon for this purpose, I wish I would have seen it earlier. This would have honestly been discouraging enough to consider Ruby on Rails or Django instead. But alas, thanks to a handy video I found, I was able to get it going. I look forward to trying Laravel still.
If you need help getting Laravel going and you don't mind using something other than (Virtual Box + Vagrant + Composer + Homestead), you might consider using Xampp or Wamp. Here's a link to the tut I used. https://www.youtube.com/watch?v=JNn_tS2KpcY
Dan Donche
6,214 PointsDan Donche
6,214 PointsI agree with your assessment of Homestead, it'll allow me to keep everything updated, dependencies, etc. etc. I just got super frustrated. As much as I love computers and code, I hate them at times also. Maybe in the future I'll put Ubuntu on a virtual drive and do things that way. I once had the same issues with Django and I tried it on my Mac and had it up and running in like 10 minutes. Thanks for your help, I will try what you suggested and see what comes of it. I will definitely be trying to get Homestead to work for the reasons you mentioned, I just needed a break I guess.