On-the-floor

On the Floor

"The OS As App" or "Developing Rails Apps on Windows (The Joyful Way)"

My situation may be specific, but I doubt it is unique. At work, I use a Mac Mini to develop Rails apps. This works well for me: I love working on Macs, Rails loves working on Macs, and life is good.

At home, though, it's a different situation. My old G4 laptop is woefully underpowered, both in terms of processing ability and battery life, and the current state of my bank account prohibits me from replacing it at this moment in time. The year-old family computer performs well, but is currently running Windows Vista, mostly because my wife uses it for work and, let's be honest, because she is comfortable and happy using it. So, if I want to write Rails apps at home, I have to find a way to do it on the Windows machine.

If you develop Rails apps for even a small amount of time, one of the first things you will notice is that you tend to be on the command line a lot. Assuming ruby and gem are already installed, rails is installed by dropping into a shell, typing 'gem install rails', and watching all the pretty text scroll by. From there, you will use the command line to: start your Rails app running; install plugins; check your Rails code into and out of your version control system; update your libraries; and deploy your app to its live home. If you are uber-hard-core, you might be actually writing your code there too.

(Photo courtesy katutaide)

Now, playing around in the command line on a Unix-like OS (OS X, Linux, whatever) is a joy. In contrast, playing around in the command line on a Windows system is like playing in a concrete-covered urban school yard, filled with vandalized play structures, broken glass and heaps of dog turds. In short, "not a joy."

I gave it a try, though, I really did. I installed ruby on the PC, then set up Rails. I installed Cygwin (an app that mimics a Unix-style shell on Windows) so that I could use it to install and run git. I tried to get sqlite3 to install with no luck, before I found out that sqlite3 probably doesn't work with ruby on Windows right now.

And then I thought, "Why am I trying so hard to make Windows work like OS X or Linux? Why don't I just INSTALL LINUX?" Now, I've been down the dual-boot road before, and I don't like it. In our house, the computer is on a lot, with my son, my wife and me switching back and forth between logins to play games, check email or develop apps (as the case may be). Having to log everyone out, restart, make sure my stuff is saved, restart, log my son in, restart, open my files again, etc. seemed like "not a joy." But luckily, that's not your only option if you want to run two different OSes on the same computer.

By using virtualization software, you can create a less-powerful version of your computer that runs on your installed OS, just like any other program. You fire it up and shut it down when you want, you can leave it running while you switch to another user, you can minimize it, whatever. The virtual computer is set up with a virtual network connection, and can use your USB connections and optical drives. On that virtual computer, you can install another OS. (On that OS, I imagine, you could even install the virtualization software and install another OS, but I haven't tried that yet.)

I chose to use VirtualBox as the virtualization software, and Ubuntu as my OS, mostly because they are both free and seem to be very usable and stable. Setting up VirtualBox was easy, just the usual download a setup exe and run it. Installing Ubuntu was just as easy. I downloaded the Ubuntu .iso file, and then created a new "Guest OS" on VirtualBox, using the .iso file as a virtual CD in the virtual CDROM drive.

After that, it was the usual "fresh OS install" stuff, like checking that I could connect to the internet, running the software updater, and changing the desktop image. After THAT, I installed the VirtualBox's "Guest Additions" for Ubuntu, which is a collection of software that modifies the guest OS installation so it integrates better with VirtualBox (stuff like automatically changing the display settings of the virtual computer to match the size of the window it's running it, and auto-grabbing the mouse and keyboard when you click on the guest OS). Finally, I installed ruby, rails, git, the sqlite3 driver for ruby (yay!) and now I'm happy again.

There are downsides to running an OS on top of another in this way, mostly performance ones. When you set up the guest OS, you need to specify how much of your memory it is allowed to command, and so that memory is unavailable to the host OS while it is running. Similarly, you also need to allocate a certain amount of hard-drive space to the guest OS. But in my case, these aren't that much of a worry. Ubuntu seems to run fine with the 384Mb of RAM I allocated to it, and web development is mostly text files, which aren't really that big.

I was very impressed by how easy it was to set this up my system. Being able to run an OS as just another app has allowed me to do things my way, and I am once again finding it a pleasure to develop on my home computer.

 

Comments

On April 14 2010 at 9:38PM Mitchell Hashimoto said:

Marc,

Great post! I agree that virtual machines are the way to go for rails development on Windows. I also believe that virtual machines are actually the way to go for web development in general on any OS! There are many benefits to developing in a VM over your typically OS:

* Reproducible environment that mirrors production.
* Isolation from your other processes
* Easily stop the VM to stop all processes related to development (server processes, background jobs, etc.)

Long story short: What you described in this post is what I enjoy doing so much that I, along with John Bender, built a tool to streamline/automate the process: Vagrant (http://vagrantup.com)

This tool doesn't currently work on Windows (but 100% windows support is coming with the next release, barring any major issues), but I still think its worth taking a look at.

Another interesting issue which Vagrant would help you with is transporting your development environment to/from work. With Vagrant, you could stop your VM at work, take it home, and start it back up again (on Windows!) and have it all be the same.

Anyways, I tried to make sure my plug for my own tool was short and near the end of this comment because the main purpose of this comment was to agree with you and post some points on why web development in a VM is a good thing.

Thanks for the read,
Mitchell Hashimoto

Add a Comment

Your Comment:

Your Name:

Your Email Address: (Won't be published)

Your Website: (If you've got one)