簡體   English   中英

為JRuby安裝hpricot

[英]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版。

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

HPricot使用本機C擴展,並且不符合FFI。 因此,它不能在JRuby下使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM