Why I Develop in a VM
10 Jul 2014"I do Rails development on Windows. On a Surface in fact."
Inevitably, whenever someone asks about development environments, I like to toss this one out there. In part, because I think the legion of "you're not cool if you're not on a Mac" developers is somewhat tiresome, and in part because it's true.
Confession time though. I don't really develop on a Surface. I develop in an Ubuntu Server VM, which just so happens to run in VMWare Player on my Surface. With 8gb of RAM and a reasonably modern processor, it has more than enough "oomph" to run Ubuntu and OSX VMs side by side, while I do the actual coding in Sublime Text just like everyone else. Bonus: the Windows version of Sublime has the same keyboard commands
So why go through the trouble? To explain that is to talk about the young days of Rails. When I first started developing in Rails (way back in the 1.x days), Windows support was lackluster to say the least. You could go the patchwork Cygwin route, or you could install Locomotive, an awesome standalone environment from Engine Yard. The company I worked for was entirely OSX or Linux, and not caring much for OSX at the time, I decided to go the Ubuntu route. Unfortunately for me, I wasn’t much of a Linux kid - I knew my way around, but only insomuch as it was “like DOS with the safety off”, and installing stuff involved invoking a magical “make && sudo make install” rather than running an installer. Not exactly Ninja-level stuff.
So when I was handed my first Linux box (a beefy workstation from the great folks at PogoLinux) and told “Go to RubyOnRails.org, follow the setup guide and let me know when you’re all set,” I was a bit out of my element. Getting Ruby and Ruby Gems up and running was easy enough, and the Ubuntu desktop interface was Windows-y enough at the time that I could muddle through. Still, it always felt like I was out of my element, and a lifetime of DOS/Windows machines hadn’t prepared me for a system like this. Where’s an image editor? What if I just want to read a text file? How come there’s no Macromedia Flash plugin for the browser? A steep learning curve at a new job full of very smart people.
Long story short, and thanks to some patient co-workers and the Rails community’s fondness for posting solutions online, I got it up and running. But then my first project involved trouble-shooting something with ImageMagick, which was (even moreso than these days), well, magic. And I don’t mean magic in the Apple marketing sense, I mean it in the “gathering obscure components, tapping of eldritch energies, and performing a blood sacrifice” kind of magic. At some point, I broke it.
And when I say “broke” - I mean something I did caused my entire Ruby / gcc / environment to become unusable. Knowing what I know now, I likely broke a bunch of my environmental variables. But getting started with a new job, new language, and a new OS all at once was too much, and my machine paid the price. A few hours of wiping and starting from scratch later, I was ready to go, but that experience stuck with me.
A few years later (and a good bit more clever in a Linux world), I found myself at another job, and this time I had my pick of machines. I’d missed working in Windows, especially for all the things that a non-developer needs to do. Document preparation, principally, consumed my days as a product manager in a highly regulated industry. Test specs and design specs and functional requirements were dozens of pages long, and I had to author some aspect of all of them. But I also started writing a web service for tracking some sales requests. Naturally, I threw a (newly acquired) PogoLinux box under my desk and started writing. My first attempt involved setting up WinSCP to monitor my project directory and mirror it to the server. It worked pretty well, all things considered, especially as we were on the same LAN. At some point, the little tool I was building got useful, stopped being a shadow IT project, and needed to be run on our VM farm. Talking to friends over in IT, it turned out they could give me an image that would run a (nearly identical) version of the server VM right from my machine, so I could do my development there and then just post it when I was done. This also prevented the “live editing” I was doing at the time, which meant that I didn’t have to take down a critical tool just to work on it. I was sold – I’d never have to tie my main OS and my need for development tools together again.
Over the years, I've found there are some significant advantages to developing in a VM, especially (when possible), one per project. Before the days of bundler and RVM, it kept gems and ruby versions isolated, so you didn’t accidentally forget to include some gem you needed. Small VMs with wimpy memory and processor allocation could accurately recreate a low-powered server and not trick me into thinking something would work well at scale just because it ran great on my local machine. I could move easily between machines without much headache. I can test in IE and Safari in their native OS, and run Chrome for both Mac and Windows (and they’re different, try as Google might to make them the same).
Most importantly though, if I was going to do something risky (like a major OS upgrade), I could just clone the VM, and when it up-ended (as it still does, from time to time), I just nuke it and start from scratch.
You can find a good text editor for any OS. You can run a VM of just about anything on just about anything else these days. Yes, that means I can even boot OSX 10.9 on my Windows 8.1 machine and search for whatever obscure and elusive Safari bug is plaguing my latest bit of Javascript.