[英]Installing hpricot for JRuby
我正在尝试为Rails上的Jruby看黄瓜。 webrat是先决条件之一,它具有必备的hpricot。
我已经使用以下方法将宝石与hpricot一起安装:
gem install hpricot --source http://code.whytheluckystiff.net --version 0.6.1 --platform java
这将安装hpricot的Java版本。 我将hpricot_scan.jar添加到CLASSPATH中,但是在运行时:
cucumber features -n
我得到以下输出:
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'
等等
如果我编译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"'
如果我尝试安装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
有人对我做错了/没有做/在哪里变得愚蠢有任何线索吗?
使用Windows XP,JRuby 1.2.0
由于Ola Bini上个月重写了对hpricot jruby的支持,因此可以在jruby中安装hpricot的git head 。 只需下载头像,然后使用
jruby -S rake package_jruby
cd pkg
sudo jgem install ./hpricot-0.8.1-jruby.gem
而且你应该是黄金的。
我不了解黄瓜,但是绝对可以在JRuby 1.2.0中使用Hpricot(尽管不是最新版本的Hpricot)。 您安装了哪个版本的Hpricot? 也许与其他库不兼容?
以下命令对我有用:
jruby -S gem install hpricot --version '~>0.6.1'
仅供参考,JRuby 1.4版现在支持HPricot 0.7版。
HPricot使用本机C扩展,并且不符合FFI。 因此,它不能在JRuby下使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.