Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Vagrant 1.2.2: Can’t Convert Symbol into Integer (TypeError)

DZone's Guide to

Vagrant 1.2.2: Can’t Convert Symbol into Integer (TypeError)

· DevOps Zone ·
Free Resource

The need for DevOps innovation has never been greater. Get the results from over 100 business value assessments in this whitepaper, Digital Darwinism: Driving Digital Transformation, to see the positive impact of DevOps first hand.

As I mentioned in my previous post I’ve been playing around with Vagrant for the past couple of days and I was trying to adapt a Vagrantfile that Nathan created a few months ago to do what I wanted.

I’m using Vagrant 1.2.2 and I started out with the following Vagrantfile:

Vagrant.configure("2") do |config|   
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
 
  config.vm.define :neo01 do |neo|    
    neo.vm.network :hostonly, "192.168.33.101"
    neo.vm.forward_port 8080, 4569
  end
end

Unfortunately a ‘vagrant up’ doesn’t quite work as expected:

$ vagrant up
/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/kernel_v2/config/vm.rb:146:in `[]': can't convert Symbol into Integer (TypeError)
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/kernel_v2/config/vm.rb:146:in `network'
	from /Users/markneedham/projects/support/haproxy/Vagrantfile:19:in `block (2 levels) in <top (required)>'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/v2/loader.rb:37:in `call'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/v2/loader.rb:37:in `load'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/loader.rb:104:in `block (2 levels) in load'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/loader.rb:98:in `each'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/loader.rb:98:in `block in load'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/loader.rb:95:in `each'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/config/loader.rb:95:in `load'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:329:in `machine'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/plugin/v2/command.rb:131:in `block in with_target_vms'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/plugin/v2/command.rb:164:in `call'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/plugin/v2/command.rb:164:in `block in with_target_vms'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/plugin/v2/command.rb:163:in `map'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/plugin/v2/command.rb:163:in `with_target_vms'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/up/command.rb:42:in `block in execute'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:206:in `block (2 levels) in batch'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:204:in `tap'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:204:in `block in batch'
	from <internal:prelude>:10:in `synchronize'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:203:in `batch'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/up/command.rb:41:in `execute'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/cli.rb:46:in `execute'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:467:in `cli'
	from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/bin/vagrant:84:in `<top (required)>'
	from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'
	from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `<main>'

The problem line is ‘neo.vm.network :hostonly, “192.168.33.101″‘ which I learnt is because the way you setup networking has changed slightly between the versions.

We now need something like this:

Vagrant.configure("2") do |config|   
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
 
  config.vm.define :neo01 do |neo|    
    neo.vm.network :private_network, ip: "192.168.33.101"
    neo.vm.forward_port 8080, 4569
  end
end

If we run ‘vagrant up’ again we’ll see that error has been removed and we have a new one!

$ vagrant up
Bringing machine 'neo01' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:
 
vm:
* The following settings don't exist: forward_port

It turns out the way that we do port forwarding has also changed. Annoyingly if you google ‘vagrant port forwarding’ it still points you to the old documentation rather than the newer one.

We need to change our code to the following:

Vagrant.configure("2") do |config|   
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
 
  config.vm.define :neo01 do |neo|    
    neo.vm.network :private_network, ip: "192.168.33.101"
    neo.vm.network :forwarded_port, host: 4569, guest: 8080
  end
end

If we run ‘vagrant up’ now it’s much happier:

$ vagrant up
Bringing machine 'neo01' up with 'virtualbox' provider...
[neo01] Setting the name of the VM...
[neo01] Clearing any previously set forwarded ports...
...

Interested in Kubernetes but unsure where to start? Check out this whitepaper, A Roundup of Managed Kubernetes Platforms from Codeship by Cloudbees, for an overview and comparison of Kubernetes platforms. 

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}