But it works on my machine

But, it worked before you broke it. It ain't my problem. You understand? It worked. It worked before you broke it!

  -- Louie, The Super (1991)

A developer writes code on their local machine, tests, commits, pushes, builds, deploys... then breaks production:

(╯°□°)╯︵ ┻━┻

"WTF happened? But it works on my machine!"

There's a lot of things that could have gone wrong, but here's a few things I've seen come up time and time again over the past few years. Things that could have easily been prevented:

These silly mistakes, and a lot more like them, could have easily been prevented if the developer tried to remove the differences between their development environment and production.

One of the best ways I've found to do this is to replicate production in virtual machines, and then only do development there. No exceptions. For the past couple of years, to force myself to stick to this plan, I've made sure to never install development tools locally. This even means I don't even have an editor configured outside of a virtual machine. Yuk!

Disposable Environments

It sounds silly even having to write this down as it's so damn obvious, yet I've found hardly anyone does it! There are various reasons given, but the most common I hear is

"that's just too much effort".

This is why I love Vagrant! Vagrant is a manager for virtual machines. It makes bringing up and destroying virtual machines completely painless, even to the point of being able to treat VMs as disposible environments. And combined with something like Ansible, you've got the superpower of repeatedly deterministic environments! What an awesomely freeing concept.

Update: If you don't require the hardware isolation that's afforded to you by virtual machines, just use Docker - it's awesome (and faster)!

Once you're in that nihilist mindset, gone are the days of careful curation of precious little boxes. You'll never edit config files with the fear that you may break that 8 month old developer box for good. Instead you just tear down the box, make a cup of coffee, then when you come back, it's like you never left.

Git took off because it made branching painlessly quick and simple. Feel like experimenting with a project but don't want to lose the world? Branch the repo. Same deal here, but at the machine container level...

VM || GTFO.

Update: Docker || GTFO.