possible to load nokogiri in jruby without install

2019-04-14 12:42发布

i need a way to run following nokogiri script

#parser.rb
require 'nokogiri'

def parseit()
//...
end

and call the parseit() while running below main.rb in jruby

#main.rb
require 'parser'

parseit()

Of course the problem is jruby cannot find 'nokogiri' as I have not installed it aka nokogiri-java via jruby -S gem install nokogiri

The reason is there is some bug I found in nokogiri running under Jruby, so I have only installed nokogiri on Ruby not Jruby. The parser.rb runs perfectly under just Ruby.

So my objective is to be able to run parseit() without having to install nokogiri on Jruby!

4条回答
Viruses.
2楼-- · 2019-04-14 12:53

Nokogiri should work under FFI in JRuby. See http://www.ruby-forum.com/topic/186274

查看更多
Juvenile、少年°
3楼-- · 2019-04-14 13:00

Nokogiri works just fine under JRuby (1.4.0 has issues, but the 1.4.1 version of the gem has been working perfect for me).

jruby -S gem install nokogiri

and if you have issues with platform detection you can force it:

jruby -S gem install nokogiri --platform=java

You shouldn't have any issues using it with JRuby, if you are then maybe you're stack isn't right.

查看更多
The star\"
4楼-- · 2019-04-14 13:10

Nokogiri should just work with JRuby via FFI, so it seems to me that the best course of action is just figure out why installing nokogiri in JRuby doesn't work for you.

What kind of problems you see? What JRuby version? What platform?

查看更多
smile是对你的礼貌
5楼-- · 2019-04-14 13:12

Here's an example of a situation where it would appear that the Java implementation of Nokogiri is producing different results from the C version, which is causing the loofah gem to fail a bunch of JRuby tests. This is blocking the ability of the Redmine developers from supporting JRuby.

https://github.com/flavorjones/loofah/issues/88#issuecomment-122747924

查看更多
登录 后发表回答