Friday, November 16, 2012

Finally there is a cure for Ruby on Rails on Windows... Vagrant.

Ruby on Rails (RoR) on Windows is a pain! I have been searching for a simple solution for a long time. There are a few solutions out there but most of them were not good enough for me. Recently I discovered Vagrant and everything has changed. But before we dive into Vagrant let me highlight the issues I had with the other solutions.

RailsInstaller is the most popular solution for RoR on Windows. It's a one click installer that installs Ruby, Rails and even Git. The problem is that a lot of gems are not compatible with Windows so you might eventually hit a roadblock if you are someone who depends on 3rd party libraries.

Another commonly suggested solution is to run a linux distro through virtualization software such as VMWare or VirtualBox. This solution is a good one if you have powerful hardware. If you don't it'll definitely slow down your computer. Prior to Vagrant this was the best solution and I think it's actually the bases for Vagrant.



What is Vagrant? 

Vagrant is simply a light-weight virtual machine that allows you to have a full linux environment (commonly Ubuntu Lucid 32) through which you can do your development. It is similar to working on a linode vps, if you have experience with one of those. 

Difference between Vagrant and standard Virtual Machines (VMs)?

Vagrant is very light-weight. Vagrant's virtual machine uses only about 50-60MB of RAM and you will not even notice it's presence (I don't).

There is no GUI (graphic user interface). You run every thing via SSH into the virtual machine. All GUI tasks like code editing can be done through your Windows based text editor. And it all integrates very nicely.

More advantages

With Vagrant you can setup your environment and using one command save that environment into a package  which you can give to a colleague or transfer to another machine and it'll all be setup exactly the same way. How cool is that? 

Experiment with multiple configurations without having to worry about damaging your system. This is immensely helpful when upgrading your system.

Did I mention it is FAST? I mean native Linux fast. You will not notice any lag whatsoever when you run  rails commands as you will in Windows.

Port forwarding makes you run rails server just like it was running natively in Windows. Just point your browser to the port you have specified and voila!

Conclusion

I have not been using Vagrant for even more than 24 hours so forgive me if I have left some stuff out or got some stuff wrong, but this is just a brief summary of why I think it is just so awesome.

In my next post I will describe into detail how to setup Vagrant for Ruby on Rails development on Windows.


... now excuse me as I go delete my Ubuntu partition (oh... did that already).