#27 ✓resolved

Switch to Nokogiri prevents JRuby use of Webrat

Reported by Si | November 9th, 2008 @ 11:18 AM

The Hpricot gem could run under JRuby, so that Webrat worked fine, but the switch to Nokogiri prevents this.

Looks like there is no support for JRuby in Nokogiri, and the Nokogiri gem silently fails to build native extensions on my OSX box. I had hoped this meant that alternative non-native code would be used, but sadly no:

jruby -S gem install nokogiri
Building native extensions. This could take a while...
Successfully installed nokogiri-1.0.3
1 gem installed
Installing ri documentation for nokogiri-1.0.3...
Installing RDoc documentation for nokogiri-1.0.3...

The problem is hit when starting cucumber, which requires Webrat. The requiring of nokogiri fails to include the native code, and there's no JRuby platform alternative:

jruby -S cucumber .....
lib/cucumber/cli.rb:131:in `require_files': no such file to load -- nokogiri/native (MissingSourceFile)
Failed to load features/steps/env.rb

It would be great to use Webrat alongside Celerity under JRuby, so I hope a solution can be found. I'm really keen to use Webrat with my feature steps instead of going directly to celerity.

Comments and changes to this ticket

  • Bryan Helmkamp

    Bryan Helmkamp November 13th, 2008 @ 11:28 PM

    Hey Si,

    Thanks for the ticket. I agree.

    I worked on this a little this week and wanted to let you know it's a priority. If you checkout the latest code, it should fall back to Hpricot for parsing and searching if nokogiri doesn't load. I haven't tested it under JRuby yet though, so there might still be some issues.



  • gaffo

    gaffo November 14th, 2008 @ 12:22 PM

    Yes, I just upgraded on my linux box and didn't have nokogiri either and I got the same issue, so the failover isn't yet working.

    Unfortunatly I just threw nokogiri on all of my machines so to test it you're going to have to remove the nokogiri method or mock out require :).

  • Bryan Helmkamp

    Bryan Helmkamp November 17th, 2008 @ 12:06 AM

    • State changed from “new” to “resolved”

    I believe I've resolved the issues with Webrat on JRuby.

    Si -- Nokogiri doesn't distribute the CSS part of the library separately, but there is a Nokogiri gem for JRuby. At the moment, it's good for using the CSS part of the library (which works on JRuby), but not the main Nokogiri stuff (which only works on MRI). nokogiri/css is not (or at least shouldn't be) dependent on the nokogiri core.

    So Webrat requires Nokogiri when run on either MRI or JRuby. On MRI, it uses Nokogiri for everything. On JRuby it uses Nokogiri's CSS support, and then Hpricot + REXML for XML parsing and searching. The hope is that Nokogiri will support JRuby fully soon, and then we can stop using Hpricot and REXML entirely.

    Here's how the code looks now:

    if RUBY_PLATFORM =~ /java/
      # We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
      require "nokogiri/css"
      require "hpricot"
      require "rexml/document"
      require "nokogiri"
      require "webrat/core/nokogiri"

    Let me know if you run into any further issues with this. Also, please keep me posted on your use of Webrat with Celerity. If it's workable, I'd like to get it into Webrat proper.



  • Bryan Helmkamp

    Bryan Helmkamp December 2nd, 2008 @ 01:50 AM

    Clemens -- Try:

    sudo jgem install nokogiri

  • Bryan Helmkamp

    Bryan Helmkamp December 2nd, 2008 @ 01:24 PM

    Haven't seen or heard of that issue before. It would be best to open a ticket on the Nokogiri ticket tracker, as they'd be better able to help with the install issue:


Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket