Vag’rant 1.2.x or the missing upgrade manual

In this article, I will show you the issues you will encounter to upgrade vagrant from 1.0.x to the 1.2.x and how to fix them.

You will need to
– update vagrant it-self
– update the Vagrantfile
– migrate your base boxes to the new layout

Upgrade Vagrant it-self

First the distribution of the software is no more handled by rubygems, so first uninstall all previous vagrant gem versions.

gem uninstall vagrant

also remove any reference to vagrant from your Gemfile.

-gem 'vagrant' 

Then download the new version os-package depending on your distribution and install it.
For my ubuntu laptop it looks like this :

sudo dpkg -i vagrant_1.2.2_x86_64.deb
rm vagrant_1.2.2_x86_64.deb

Upgrade the Vagrantfile

Vagrant 2.0 final will have a stable Vagrantfile format that will remain backwards compatible, just as 1.0 is considered stable.

vagrant up… and then the trouble begins :

A Vagrant 1.0.x state file was found for this environment. Vagrant has
gone ahead and auto-upgraded this to the latest format. Everything
should continue working as normal. Beware, however, that older versions
of Vagrant may no longer be used with this environment.

However, in case anything went wrong, the old dotfile was backed up
to the location below. If everything is okay, it is safe to remove
this backup.

Backup: .../.vagrant.v1.1372160849
.... Vagrantfile:3:in `local_cache': uninitialized constant Vagrant::Environment::DEFAULT_HOME (NameError)

No luck for the backup is polluted with a .vagrant, my Vagrantfile is empty. Thanks to git I can restore it

git checkout -- Gemfile

uninitialized constant Vagrant::Environment::DEFAULT_HOME (NameError)

Now lets fix the first errors, as I was using this gist to cache on my laptop the apt artifacts.
We should replace the DEFAULT_HOME with current directory

   File.expand_path(Vagrant::Environment::DEFAULT_HOME) to              

Don’t forget to add the cache directory to your .gitignore

Shared folders

The apt cache solution is working with a share folder between my laptop, and it’s also affected by a dsl change in vagrant :

config.vm.share_folder "v-cache", "/var/cache/apt/archives/", cache_dir 

is now called synced folder :

config.vm.synced_folder cache_dir, '/var/cache/apt/archives/', id: 'v-cache', owner: 'vagrant', group: 'www-data' 

Forwarded port


config.vm.forward_port 80, 8080

with the upgraded dsl : :forwarded_port, host: 8080, guest: 80  

Network hostonly

A small config changes from :hostonly, "" 

to :private_network, ip: ""

Customize natdns

Previously I was enabling memory and natdns properties via

config.vm.customize(["modifyvm", :id, "--name", "dev-dev606", "--memory", "1024",

These customizations are now specific to the virtualbox provider :

config.vm.provider 'virtualbox' do |v|
      'modifyvm', :id,
      '--name', 'dev-dev606',
      '--memory', '1024',
      '--natdnshostresolver1', 'on',
      '--natdnsproxy1', 'on'

Boot with ui

Sometimes you need to boot the vm with a gui (to diagnose boot issue, clear bad firewall rules)
Previously it was :

  config.vm.boot_mode = :gui

Not this is done via the provider

config.vm.provider "virtualbox" do |v|
  v.gui = true

System call

I used to have a call to librarian-puppet. But now it’s complaining that he can’t find his own gem. Thats because we are launching it in a vagrant with sandboxed ruby that has ownly access to vagrant dependencies. My work around for now is to prefix the call with a rvm use.

 system "/bin/bash -c -l 'rvm use ruby-2.0.0-p247 && cd #{File.dirname(__FILE__)} && bundle exec librarian-puppet install'"

If somebody know a better way to escape the sandbox… leave a comment.
Did someoned knows if librarian-puppet-vagrant is vagrant 1.2 compatible ?

Update your existing base box

The basebox layout has changed (to support multiple provider), it seems that the code that is supposed to upgrade it isn’t working for me.

So here you have the manual steps to migrate them :

cd ~/.vagrant.d/debian607
mkdir virtualbox
mv box-disk1.vmdk box.ovf Vagrantfile virtualbox
cd ../working-box

Then add a metadata.json in ~/.vagrant.d/debian607

cat << EOF > metadata.json
  "provider": "virtualbox"


This upgrade wasn’t really transparent for me. It makes me sad when I think about all these obsolete/broken articles on the net, all these books that will need a second edition. I hope it will not discourage the vagrant adoption too much.

You can use the new plugins :

vagrant plugin install vagrant-vbguest

My final Vagrantfile is available here.

  1. #1 by Patrick on May 29, 2014 - 5:07 pm

    Glad to find a upgrade post about your caching gist. (Can you update this btw?)
    With the Environment and synced_folder error fixed it now works for me. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: