labs

Improving the JRuby toolchain

Recently we’ve seen an uptick in JRuby projects coming through the door, especially with our enterprise clients. This has been both a blessing and a curse. On the one hand we have to leave our familiar and reliable MRI environment, on the other we still get to use our skills and tools from the Ruby ecosystem. I’ve been really encouraged with the feature parity of JRuby and look forward to the enterprise considering it as a legitimate solution.

That said, we did run into a couple of gotchas for some of the gems we depend on. We make heavy use of capybara-webkit for headless acceptance testing and it didn’t explicitly have JRuby support. Luckily there were only a couple of failing tests and we could call on maintainer and ex pivot Matt Horan for some guidance. With his help we managed to:

Fix killing webkit server when a test suite completes
Fix some failing IO tests
Get a passing JRuby build up an running on travis

A couple of projects also use warbler to create standard .war packages that can be deployed on Tomcat. Warbler and git sourced gems need a little extra config to play nice. We were seeing the following error:

Bundler::GitError: https://github.com/gregbell/active_admin.git (at master) is not yet checked out. Run `bundle install` first.

It turns out that warbler 1.4.0 overrides GEM_HOME by default. Combined with RVM this was the root of our problem. The following simple config tweak ensures warbler builds the package and looks in the correct paths when executed:

   # config/warble.rb
   Warbler::Config.new do |config|
      # ...
      config.override_gem_home = false
   end