Vagrant doesn't make it easy to manage multiple versions of it. I was lucky enough to ended up working on a project whose vagrant up only works with the legacy Vagrant 1.4 and another one that only works with newer versions. I'll explain here how I managed to keep both. In this case I'll install Vagrant 1.4.3 and 1.7.4 (the newest as of now), but in principle it should work with other versions as well.
1. Install VirtualBox 4.3 and Vagrant 1.4.3
Vagrant 1.4.3 doesn't work with newer versions of VirtualBox (>4.3). During this experiment I messed up all my installations several times, so I'm installing everything from scratch (just go to the download page, download the dmg and run the pkg installer normally).
$ sudo mv /Applications/Vagrant /Applications/Vagrant\ 1.4.3
$ sudo ln -Fs /Applications/Vagrant\ 1.4.3/bin/vagrant /usr/bin/vagrant
* This is for legacy Vagrant versions, which are installed in /Applications/Vagrant.
Vagrant 1.7.4 is organized differently from 1.4.3 and, when running a command that requires application data for the first time (e.g. vagrant box list), it will update its file structure, breaking the 1.4.3 installation. To prevent this from happening, run:
$ sudo mv ~/.vagrant.d ~/.vagrant143.d
* You can run this after installing 1.7.4, just make sure you don't run any vagrant command before.
Now you're safe to install Vagrant 1.7.4. When you're done you can check if everything is ok:
$ rehash
$ vagrant -v
Vagrant 1.7.4
* If you're still getting 1.4.3, just open a new shell.
$ sudo mv /opt/vagrant /opt/vagrant174
$ sudo ln -Fs /opt/vagrant174/bin/vagrant /usr/bin/vagrant
* This is for new Vagrant versions, which are installed in /opt/vagrant.
Add these lines to your ~/.bash_profile (or ~/.zshrc or whatever you use):
alias vagrant143='sudo ln -Fs /Applications/Vagrant\ 1.4.3/bin/vagrant /usr/bin/vagrant && mv ~/.vagrant.d ~/.vagrant174.d && mv ~/.vagrant143.d ~/.vagrant.d'
alias vagrant174='sudo ln -Fs /opt/vagrant174/bin/vagrant /usr/bin/vagrant && mv ~/.vagrant.d ~/.vagrant143.d && mv ~/.vagrant174.d ~/.vagrant.d'
Now you can easily switch between versions by running vagrant143 or vagrant174:
$ vagrant143
$ vagrant -v
Vagrant 1.4.3
$ vagrant174
$ vagrant -v
Vagrant 1.7.4
Note that your vagrant boxes will be stored separately, so if you add a box while using a version of Vagrant it won't be visible from the other version:
$ vagrant143
$ vagrant box add trusty64
$ vagrant box list
trusty64 (virtualbox)
$ vagrant174
$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.
These are all a bunch of ugly hacks and I can't promise a new Vagrant version won't break it, but for the moment it does the trick for me.
Thanks a lot for this gist Ariel. You are a life saver.