joe-niland / bedrock-windows

A PowerShell script to automate creation of a new bedrock Wordpress site, using Chocolatey, vagrant and ansible.
MIT License
5 stars 1 forks source link

`vagrant up` fails with uninitialized constant YAML error #5

Open rtpHarry opened 9 years ago

rtpHarry commented 9 years ago

Everything has installed cleanly now but I'm still getting this problem:

PS E:\WordPress\Themes> cd .\bedrock-ansible
PS E:\WordPress\Themes\bedrock-ansible> vagrant up
E:/rtpSoftware/WordPress/Themes/bedrock-ansible/Vagrantfile:26:in `block in <top (required)>': uninitialized constant YAML (NameError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/v2/loader.rb:37:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/v2/loader.rb:37:in `load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:103:in `block (2 levels) in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:97:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:97:in `block in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:94:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/config/loader.rb:94:in `load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:28:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:691:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:691:in `vagrantfile'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:441:in `host'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:207:in `block in action_runner'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:33:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:33:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:428:in `hook'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:673:in `unload'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/bin/vagrant:177:in `ensure in <main>'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/bin/vagrant:177:in `<main>'

I've tried searching and I think that it's something to do with this snippet that I found on stackoverflow:

YAML::ENGINE doesn't exist in Ruby 1.8.7. This is defined in Ruby 1.9.

As I've already said, this is basically my first day working with powershell, vagrant and all this stuff. I don't know where to start trying to figure out what version of Ruby is installed or if its a bug in your script or in vagrant? Any thoughts? After spending the last 4-5 hours chipping away at these issues it seems that this is finally the one thats beat me.

rtpHarry commented 9 years ago

I still haven't solved it but just adding a couple more things I've tried:

Navigating to the embedded ruby.exe in powershell and checking what version it is:

PS C:\HashiCorp\Vagrant\embedded\bin> .\ruby.exe --version
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]

Typing ruby in the bedrock-ansible folder to see if some other version might be in the path. Says command not found.

Moved the vagrant path to the start of the PATH env and restarted powershell. Hoped if anything else was interfering it would short circuit after finding it in the initial path.

rtpHarry commented 9 years ago

YES! I found a solution :)

You just need to add this at the top of the Vagrantfile file:

require 'yaml'