I destroyed my dev-environment. Again.
It all started with an upgrade of my packet management system. After previous disastrous experiences, I tried to minimize my installed packages (libpng, libjpeg, ImageMagick, PostgreSQL, MySQL, Redis) and it worked well so far. What could possibly go wrong? Short answer: almost everything.
ImageMagick and OpenCV (both depend heavily on libpng and libjpeg) broke completely
PostgreSQL updated to a new major version and needed a manual upgrade
Redis refused to start
The saddest part: It took me several days to realise the extend of the disaster.
There has to be a better solution for this. And there is one. In fact, there are plenty.
Some time ago I started using VMWare for Qt development. Mainly because I wanted to work in an environment close to production. There I got a taste of how painless a development environment can be. I updated my host system, moved the virtual machine to another device – no problem. But it had its drawbacks. It felt slow and inconvenient.
I found my peace with Vagrant and VirtualBox. To spin up a box with Ubuntu 12.04 you simply type
vagrant init precise64 && vagrant up
To access your new virtual machine just type
vagrant ssh
It’s as simple as that.
Vagrant is configured via a text-file called Vagrantfile. It is generated in the folder in which you issued “vagrant init”. To mount a folder of your host machine in your guest system, simply add
config.vm.synced_folder “my/local/project/folder”, “/var/www/html”
inside your Vagrantfiles config block. Now I can use my favourite IDE/Editor on my favourite system and the code can run inside an almost production environment.
You can even add your Vagrantfile to your projects git repository and share it with your team. To bootstrap your virtual machine, Vagrant offers several interfaces to provisioning systems (even as simple as a shell script).
One of my next blog posts will be about provisioning a vagrant machine with chef and adapting the bootstrapping for a production setup.
Well done! Thanks for this blog entry!