Thursday, April 17, 2014

Vagrant shows startup warnings about Vagrantfile using earlier version syntax

Problem

My vagrant shows the following message when I try to bring up my vagrant 

There were warnings and/or errors while loading your Vagrantfile
for the machine 'default'.

Your Vagrantfile was written for an earlier version of Vagrant,
and while Vagrant does the best it can to remain backwards
compatible, there are some cases where things have changed
significantly enough to warrant a message. These messages are
shown below.

Warnings:
* `config.vm.customize` calls are VirtualBox-specific. If you're
using any other provider, you'll have to use config.vm.provider in a
v2 configuration block.


The issue seem to be because I was using vagrant 1.3.5 and was using some older syntax
Vagrant::Config.run do |config|
  config.vm.box = "precise64"
  config.vm.forward_port 8080, 8080
  config.vm.share_folder("vagrant-root", "/vagrant", ".")
  config.vm.customize ["modifyvm", :id, "--memory", 4096]
end


Solution

I changed my Vagrantfile as follows as my error/warning is gone now..During the transition I got the following error

There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The following settings shouldn't exist: forward_port, share_folder

as I was using configure("2") and using older syntax for forwarding ports and sharing folders, which also got fixed with the following updates


Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.network :forwarded_port, guest: 8080, host: 9090, auto_correct: true
  config.vm.synced_folder "/Users/Naga/Downloads/Software/AHold", "/Software"
  config.vm.provider :virtualbox do |vb|
     vb.customize ["modifyvm", :id, "--memory", 4096]
  end

end


1 comment: