tl;dr I recently set up a JRuby on Rails development environment on Windows after using Mac OS X and Ubuntu VMs. It’s noticeably faster for development and more comfortable. I’ll stick with it.
When I was first starting JRuby on Rails development, I started with a Mac OS X environment running from VirtualBox. I chose Mac OS X to emulate as close as possible what the other members in my team were using, so I could get advice on the basics without too much friction. However, Mac OS X isn’t officially supported by VirtualBox and the environment was unwieldy – no ability to resize the VM window, no shared clipboard and occasionally crashes on boot were the main drawbacks.
After a few weeks, I moved to an Ubuntu VM. This did require minor adjustment in our codebase to get it working on a development environment. VirtualBox supports Ubuntu, and the drawbacks from the Mac OS X experience were eliminated. I used this environment for a good eight months, and became quite familiar with Unix environment. The terminal took the forefront (compared to Windows), apt-get package management was fantastic and everything felt solid. However, after copying the VM to my laptop, running Rails and tests was considerably slow.
Another reason I initially avoided Windows as a development environment was the common perception at the time was that Windows was a second-class citizen in the Ruby community, and performance was lacking. Supposedly even a Ubuntu VM would outperform a native Windows environment. Having gained significant experience with JRuby on Rails over the last few months, I felt comfortable enough to try my hand at setting up a Windows development environment. Here’s what I learnt from the process:
- Use the Java SDK instead of Java JRE to run JRuby. I would occasionally get
Cannot find Java 1.5 or highererror messages when running certain gems. Ensure
JAVA_HOMEis set to
Program Files/Java/jdk*and PATH includes
- JRuby on Windows requires the jruby-pageant gem to interact with net/ssh.
- We are using Eco templates and I was encountering
- Command Prompt and Powershell don’t natively support ANSI escape characters (e.g. colour codes). So running RSpec would insert a bunch of garbage characters in the output. Turning off
--colorhelped, but there was still some around the progress bar itself, notwithstanding the loss of coloured output. I investigated ANSICON but it seemed too complex to install and I wasn’t entirely sure I could get it working with Powershell. So I decided to install Cygwin and while doing so, thought I’d use ConEmu to unify my Cygwin and Powershell terminals under one umbrella. That’s when I found Powershell, when run through ConEmu, supports colour codes and also allowed me to navigate through irb/rails console history.
- I found PuTTY itself more convenient than running plink through Powershell as it seems to better interact with bash. PuTTY can also be set up as a task/jump-list in ConEmu to avoid typing the full command.
- You have to add your private RSA key to Pageant. I always wondered what the computer icon with the hat in my taskbar was for.
- Use PowerTab with PowerShell. It uses bash-like tab completion instead of the default cycling completion.
In the end, it’s about performance and friction. In comparison with the Ubuntu VM environment, JRuby start up time is noticeably quicker although running the entire test suite is mixed – its faster when using Poltergeist/PhantomJS for integration/feature tests, while slower using Selenium (which we’ve since abandoned). This leads me to think the original performance advice of using a Unix system was based on experience with MRI rather than JRuby.
The Windows environment itself is more familiar and I can now Alt-Tab between my IDE, terminals, file manager, and browser, and move applications to different monitors. As there are no showstoppers, I’ll be sticking with this environment for the foreseeable future.