Installing hpricot for JRuby

寵の児 提交于 2019-12-11 06:42:44

问题


I'm trying to look at cucumber for Jruby on Rails. One of the pre-requesites is webrat which has as pre-requisite hpricot.

I've installed the gem with hpricot using:

gem install hpricot --source http://code.whytheluckystiff.net --version 0.6.1 --platform java

This installs the java version of hpricot. I add the hpricot_scan.jar to the CLASSPATH but when I run:

cucumber features -n

I get the following output:

HpricotScanService.java:931:in `hpricot_scan': java.lang.NoSuchMethodError:
org.jruby.runtime.builtin.IRubyObject.getInstanceVariable(Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
from HpricotScanService.java:1324:in `__hpricot_scan'
from null:-1:in `call'
from InvocationCallback.java:67:in `execute'
from FullFunctionCallbackMethod.java:69:in `call'
from DynamicMethod.java:243:in `call'
from CachingCallSite.java:283:in `cacheAndCall'
from CachingCallSite.java:121:in `callBlock'

etc.

If I compile the HpricotScanService.java file and add the resulting .class file to the classpath, I get:

Then I should see "Run"
private method `scan' called for Hpricot:Module (NoMethodError)
features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/'
features/manage_activity.feature:9:in `Then I should see "Run"'

If I try to install later versions of the hpricot, then I get:

ERROR: Failed to build gem native extension.
C:/Program Files/Ruby/jruby-1.2.0/bin/../bin/jruby.bat extconf.rb install hpricot --platform java
C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (Not
ImplementedError)
from C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:1:in `require'
from extconf.rb:1

Does anyone have any clues as to what I'm doing wrong/not doing/where I'm being stupid.?

Using Windows XP, JRuby 1.2.0


回答1:


FYI, version 1.4 of JRuby now supports version 0.7 of HPricot.

http://jruby.org/2009/11/02/jruby-1-4-0.html




回答2:


I don't know about cucumber but Hpricot can definitely be used from JRuby 1.2.0 (though not the latest version of Hpricot). Which version of Hpricot have you got installed? Maybe it is incompatible with the other libraries?

The following command worked for me:

jruby -S gem install hpricot --version '~>0.6.1'  



回答3:


Since Ola Bini's rewrite of hpricot jruby support last month, the git head of hpricot can be installed with jruby. Just download the head, then use

jruby -S rake package_jruby
cd pkg
sudo jgem install ./hpricot-0.8.1-jruby.gem

and you should be golden.




回答4:


HPricot uses native C extensions and it not FFI compliant. Therefore it cannot be used under JRuby.



来源:https://stackoverflow.com/questions/726412/installing-hpricot-for-jruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!