简体   繁体   English

为JRuby安装hpricot

[英]Installing hpricot for JRuby

I'm trying to look at cucumber for Jruby on Rails. 我正在尝试为Rails上的Jruby看黄瓜。 One of the pre-requesites is webrat which has as pre-requisite hpricot. webrat是先决条件之一,它具有必备的hpricot。

I've installed the gem with hpricot using: 我已经使用以下方法将宝石与hpricot一起安装:

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

This installs the java version of hpricot. 这将安装hpricot的Java版本。 I add the hpricot_scan.jar to the CLASSPATH but when I run: 我将hpricot_scan.jar添加到CLASSPATH中,但是在运行时:

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: 如果我编译HpricotScanService.java文件并将生成的.class文件添加到类路径中,则会得到:

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: 如果我尝试安装hpricot的更高版本,则会得到:

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 使用Windows XP,JRuby 1.2.0

Since Ola Bini's rewrite of hpricot jruby support last month, the git head of hpricot can be installed with jruby. 由于Ola Bini上个月重写了对hpricot jruby的支持,因此可以在jruby中安装hpricot的git head 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. 而且你应该是黄金的。

I don't know about cucumber but Hpricot can definitely be used from JRuby 1.2.0 (though not the latest version of Hpricot). 我不了解黄瓜,但是绝对可以在JRuby 1.2.0中使用Hpricot(尽管不是最新版本的Hpricot)。 Which version of Hpricot have you got installed? 您安装了哪个版本的Hpricot? Maybe it is incompatible with the other libraries? 也许与其他库不兼容?

The following command worked for me: 以下命令对我有用:

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

FYI, version 1.4 of JRuby now supports version 0.7 of HPricot. 仅供参考,JRuby 1.4版现在支持HPricot 0.7版。

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

HPricot uses native C extensions and it not FFI compliant. HPricot使用本机C扩展,并且不符合FFI。 Therefore it cannot be used under JRuby. 因此,它不能在JRuby下使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM