Vagrant up error, everything else fine and dandy

When i run vagrant up I get:

Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /home/ivan/dev/fapps/Vagrantfile
Message: undefined method `to_h’ for #Hash:0x000000019f1400

Everything else includeing staging server and deployment works fine.

It seems this is the code that errors out:
if File.exists?(config_file)
wordpress_sites = YAML.load_file(config_file)[‘wordpress_sites’]
raise “no sites found in #{config_file}” if wordpress_sites.to_h.empty?
else
raise "#{config_file} file not found. Please set ANSIBLE_PATH in Vagrantfile"
end

wordpress_sites seems to be empty and it isn’t, it’s set in the development config file.

Did you set the path to the ansible folder? At the top of the Vagrantfile I believe the default entry is __dir__, you should replace that with the path to the ansible folder.

My path is set to ANSIBLE_PATH = "ansible"
Since my Vagrantfile is above ansible folder.

Did you clone the roots-example-project.com repo, or build Trellis and Bedrock from scratch?

First I cloned the Bedrock git repo, then I added the Trellis to the mix.
Trellis seems to work just fine for setting up server and deploying.

I’m running out of simple suggestions, you seem to have all the obvious stuff right… it’s tempting to assume that either Vagrant can’t find the file, or the information in the file is somehow invalid, but it could be some kind of software glitch.

Maybe you could post your file/folder structure? I don’t want to waste your time with suggestions if someone else has a better idea of what might be going wrong here.

@Ivan_Svaljek could you post the content of your development file? Seems like there is an error with the definition of the wordpress_sites hash.

mysql_root_password: devpw

web_user: vagrant

wordpress_sites:
fapps:
site_hosts:
- fapps.dev
local_path: …/site # path targeting local Bedrock site directory (relative to Ansible root)
repo: git@github.com:isvaljek/fapps.git
site_install: true
site_title: Facebook apps
admin_user: admin
admin_password: devpw
admin_email: mail@mail.com
multisite:
enabled: false
subdomains: false
ssl:
enabled: false
cache:
enabled: false
duration: 30s
system_cron: true
env:
wp_home: http://fapps.dev
wp_siteurl: http://fapps.dev/wp
wp_env: development
db_name: example_dev
db_user: example_dbuser
db_password: devpw

php_error_reporting: 'E_ALL’
php_display_errors: 'On’
php_display_startup_errors: 'On’
php_track_errors: 'On’
php_mysqlnd_collect_memory_statistics: 'On’
php_opcache_enable: 0

xdebug_install: false
php_xdebug_remote_enable: true
php_xdebug_remote_connect_back: true
php_xdebug_remote_host: localhost
php_xdebug_remote_port: 9000
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

I don’t know anything about ruby, but after a quick search, I think to_h was added in Ruby 2.0. You could run ruby -v to check that you have ruby 2.0. If you’re on less than 2.0, seems like your options are

  • upgrade ruby
  • find an alternative to to_h
  • temporarily comment out this line in your Vagrantfile.

Vagrant uses it’s own embedded ruby. I believe that changing your local ruby version would have no effect on it.

@Ivan_Svaljek, what version of Vagrant are you using? Also, please post the full error message you get when doing the Vagrant up. You can keep the code formatted by using the code button in the editor

1 Like

Damnit, @fullyint

1 Like

This is the error:

Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /home/ivan/dev/fapps/Vagrantfile
Message: undefined method `to_h’ for #Hash:0x000000024860f0

^^^^^^^^^^^^^^^^^^^^^^^

vagrant --version returns 1.4.3

That was it! I’ve installed the latest debian package and all seems well now.

Thank you all.

2 Likes