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 trialMaja B.
12,984 PointsProblems at Laravel Homestead instalation - Getting homestead.rb instead of homestead.yaml
Hi, I'm following the steps in this video https://teamtreehouse.com/library/laravel-basics/getting-started-with-laravel/installing-laravel-homestead to install Laravel Homestead but what happens is that the Homestead that gets installed on my computer is pretty different from the one the teacher in the video gets installed.
For example, the the teacher has a file Homestead/scripts/homestead.yaml, while I have a file Homestead/scripts/homestead.rb (ruby?)
His file looks pretty simple. While my file looks like this:
´´´ class Homestead def Homestead.configure(config, settings) # Set The VM Provider ENV['VAGRANT_DEFAULT_PROVIDER'] = settings["provider"] ||= "virtualbox"
# Configure Local Variable To Access Scripts From Remote Location
scriptDir = File.dirname(__FILE__)
# Prevent TTY Errors
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# Configure The Box
config.vm.box = "laravel/homestead"
config.vm.hostname = settings["hostname"] ||= "homestead"
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
# Configure A Few VirtualBox Settings
config.vm.provider "virtualbox" do |vb|
vb.name = settings["name"] ||= "homestead"
vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
end
# Configure A Few VMware Settings
["vmware_fusion", "vmware_workstation"].each do |vmware|
config.vm.provider vmware do |v|
v.vmx["displayName"] = "homestead"
v.vmx["memsize"] = settings["memory"] ||= 2048
v.vmx["numvcpus"] = settings["cpus"] ||= 1
v.vmx["guestOS"] = "ubuntu-64"
end
end
# Standardize Ports Naming Schema
if (settings.has_key?("ports"))
settings["ports"].each do |port|
port["guest"] ||= port["to"]
port["host"] ||= port["send"]
port["protocol"] ||= "tcp"
end
else
settings["ports"] = []
end
# Default Port Forwarding
default_ports = {
80 => 8000,
443 => 44300,
3306 => 33060,
5432 => 54320
}
# Use Default Port Forwarding Unless Overridden
default_ports.each do |guest, host|
unless settings["ports"].any? { |mapping| mapping["guest"] == guest }
config.vm.network "forwarded_port", guest: guest, host: host
end
end
# Add Custom Ports From Configuration
if settings.has_key?("ports")
settings["ports"].each do |port|
config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"]
end
end
# Configure The Public Key For SSH Access
if settings.include? 'authorize'
config.vm.provision "shell" do |s|
s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
s.args = [File.read(File.expand_path(settings["authorize"]))]
end
end
# Copy The SSH Private Keys To The Box
if settings.include? 'keys'
settings["keys"].each do |key|
config.vm.provision "shell" do |s|
s.privileged = false
s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
s.args = [File.read(File.expand_path(key)), key.split('/').last]
end
end
end
# Register All Of The Configured Shared Folders
if settings.include? 'folders'
settings["folders"].each do |folder|
mount_opts = folder["type"] == "nfs" ? ['actimeo=1'] : []
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, mount_options: mount_opts
end
end
# Install All The Configured Nginx Sites
settings["sites"].each do |site|
config.vm.provision "shell" do |s|
if (site.has_key?("hhvm") && site["hhvm"])
s.path = scriptDir + "/serve-hhvm.sh"
s.args = [site["map"], site["to"], site["port"] ||= "80", site["ssl"] ||= "443"]
else
s.path = scriptDir + "/serve.sh"
s.args = [site["map"], site["to"], site["port"] ||= "80", site["ssl"] ||= "443"]
end
end
end
# Configure All Of The Configured Databases
if settings.has_key?("databases")
settings["databases"].each do |db|
config.vm.provision "shell" do |s|
s.path = scriptDir + "/create-mysql.sh"
s.args = [db]
end
config.vm.provision "shell" do |s|
s.path = scriptDir + "/create-postgres.sh"
s.args = [db]
end
end
end
# Configure All Of The Server Environment Variables
if settings.has_key?("variables")
settings["variables"].each do |var|
config.vm.provision "shell" do |s|
s.inline = "echo \"\nenv[$1] = '$2'\" >> /etc/php5/fpm/php-fpm.conf"
s.args = [var["key"], var["value"]]
end
config.vm.provision "shell" do |s|
s.inline = "echo \"\n#Set Homestead environment variable\nexport $1=$2\" >> /home/vagrant/.profile"
s.args = [var["key"], var["value"]]
end
end
config.vm.provision "shell" do |s|
s.inline = "service php5-fpm restart"
end
end
# Update Composer On Every Provision
config.vm.provision "shell" do |s|
s.inline = "/usr/local/bin/composer self-update"
end
# Configure Blackfire.io
if settings.has_key?("blackfire")
config.vm.provision "shell" do |s|
s.path = scriptDir + "/blackfire.sh"
s.args = [
settings["blackfire"][0]["id"],
settings["blackfire"][0]["token"],
settings["blackfire"][0]["client-id"],
settings["blackfire"][0]["client-token"]
]
end
end
end end ´´´
The thing is that a couple of months ago I have installed ruby and python on my computer - in the same folder where I'm now installing Laravel (C:/Users/myname). So could it be that the two (Ruby and Vagrant/Laravel) kind of clash together?
I've tried to prevent this by uninstalling Ruby and Python from my computer. I think I've successfully uninstalled them. But I cannot be sure.
I'm working on Windows 8.
5 Answers
Daniel Ram
Courses Plus Student 14,808 PointsWe really need an update for this portion. installations are such a pain when steps are not the same :/
Daniel Ram
Courses Plus Student 14,808 PointsOkay so the whole idea of vagrant is to have a development environment that you can easily download and run. SO in theory, we should have access to the exact environment version of this course.
I am just trying this right now, but the idea specify the correct box version from vagrant and not use the latest version to follow this course.
Git also should have the versions of each commit, we should be able to reset the HEAD to a commit that is at the time this course was still in sync.
So try this instead:
Vagrant setup: vagrant box add laravel/homestead --box-version "0.2.0"
This was committed to the vagrant box repo about 10 months ago.
Git clone: git clone git reset --hard 1238521647a7e00ff923522853e827d84d2bd542
This commit is from Nov 9, 2014, it has the homstead.yaml file in the same location as the course.
I'm still testing this out myself, but hopefully.. This in theory, sync us back up to the course. I'll post an update if this works.
Hope this works for you too! Good luck!
Dillon Kavanagh
14,296 PointsSimplify this for people on later release Homestead.yaml is now located in Homestead/src/stubs. If on mac cd Homestead/src/stubs
Stephen Printup
UX Design Techdegree Student 45,252 PointsHey-
So I'm having similar issues (https://teamtreehouse.com/forum/vagrant-up-files-not-found), but I thought I would chime in that I found the homestead.yaml file in src/stubs and it is a bit different than your file above and more similar to the videos. However, Laravel has been updated since the video, so it is different. Bryan Knight suggested to use Composer to install the version of Laravel used in the videos.
I hope this helps.
-Stephen
Maja B.
12,984 PointsHi, thanks for your answer.
I've found homestead.yaml file in Homestead/src/stubs. It's practically the same as the file in the video.
Following the video, I've typed in all the changes and it now looks like that:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/github_rsa.pub
keys:
- ~/.ssh/github_rsa
folders:
- map: ~/Code
to: /home/vagrant/Sites
sites:
- map: laravel.dev
to: /home/vagrant/Sites/laravel-basics/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
Then I ran "vagrant up" and got this error:
c:/Users/myname/Homestead/Vagrantfile:18:in `read': No such file or directory - c:/Users/myname/.homestead/Homestead.yaml (Errno: ENOENT).
If I understand it correctly this error only tells me that it cannot find the homestead.yaml file in homestead folder. It obviously can't as the homestead.yaml file is not in that folder but in the Homestead/src/stubs folder.
So what should I do - transport homestead.yaml file into homestead folder? But is that "save" to do? Should I, besides transporting homeastead.yaml file transport, also some other file/s?
Or wouldn't it make more sense to fix "vagrant up" command in the way that it would look for a homestead.yaml file in a correct folder, that is: Homestead/src/stubs
Please let me know about your progress of installing Laravel. I've read all the stackoverflow posts you have listed and the ones linked inside of them. It seems quite a complicated subject. But I'm trying to follow, because I would really like to start using Laravel.
Stephen Printup
UX Design Techdegree Student 45,252 PointsHi Maja-
Ok, so I'm actually struggling with the same type of thing, hence the interest in your question. I'm still learning the intricacies of backend development and would also like to get Laravel up a running, however I keep getting the 'No such file or directory' on a base file or a code file. SO, in the spirit of learning I've found this video that describes in a little more detail how files named YAML work (however, it's in ruby and not entirely relevant) around 1 min 20 sec: https://teamtreehouse.com/library/build-an-address-book-in-ruby/input-and-output-2/saving-the-address-book
It's not the golden bullet, but I don't think anyone has all the answers and persistence wins in programming.
-Stephen
Maja B.
12,984 PointsThanks for the video. I have had a look at it and it does open new perspective.
Are you planning to install Laravel 4.2 or Laravel 5?
Stephen Printup
UX Design Techdegree Student 45,252 PointsMaja-
Wow, I just finished Laravel Basics and that was intense. It wasn't until the end that I felt like I was starting to pick up a rhythm. How has it been for you?
-Stephen
Maja B.
12,984 PointsHaven't even started with Laravel. I wasn't able to run homestead even though I've added ~/.composer/vendor/bin into path :(
:)
Stephen Printup
UX Design Techdegree Student 45,252 PointsIn the last video Hampton Paulk suggests watching it again and mentions it taking up to 4 times to really start to grasp the concepts. So I don't think just watching the videos would hurt your overall understanding of the framework or PHP frameworks in general. It's interesting to see how he interacts with the controller, views, routes and models to make different things happen.