Rails Development Under Windows XP or OS X or any other OS

Just what is the best way to develop Rails applications? Well my answer is a question, what's your production environment?

If you are currently developing your Rails app under Windows XP or OSX and deploying to a Linux production box, why are you not running a copy of whatever Linux flavor your production server is on in a Virtual Machine?

The only reason I could see for not doing so would be because you are lacking sufficient RAM. Which I'd find it hard to believe as it seems everyone is running around with 2GB or more and I can tell you that even with 1GB you can get away with dedicating 128MB to a VM instance. There are plenty of VM programs out there, VMWare Server and VirtualBox if you're on a PC, or for the Mac, VMWare Fusion and Parallels on the Mac .

Plus probably a dozen others that all can do the job.

After you get your favorite flavor installed with the same versions of packages that are running in production turn on samba and share out whatever directories you need. I have symlinks in my home directory to my various apps and simply share out home directories in my smb.conf. Then mount that share on your host OS. In my case my home directory is mapped to H:.

Now you can edit files from that drive with your favorite editor. Or you can do what I do and SSH into the guest OS and edit there. If you need X applications like gitk get an X server running on your host and ssh into the guest with XForwarding turned on.

All in all now you can deal with situations like "I can't get this gem installed on XP/OSX", "For some reason when I deployed my app is segfaulting", "I wonder if my app will run under this fancy new app server". Everything you do and test will be under the same environment as your production saving you time and headaches.

For me at some point along the line I realized that writing my Rapture CMS code to run on both Windows and Linux was a exercise in futility. It ate up way too much time so I decided to focus on just writing for my production environment, which was and is RedHat Enterprise (RHEL). This was back pre-0.13 days and trying to get certain things to work right under Windows XP, wether it was ruby, gems, Apache, whatever was just eating up time. It probably still would.

Using VMWare Server machine of an install of CentOS I was easily able to mimic my production environment. Yes I realize it's not a perfect mirror, but it's close enough. It has 440MB to play with out of the 2GB of RAM I have on my laptop and 12GB of hard disk space dedicated to it. More than enough to run the Mongrels I need to do debugging.

Give it a try next time you can't get that random gem to compile and it's driving you nuts for a day.

July 11th, 2008

Leave a Reply

design by gorotron ported by railsgrunt powered by mephisto