得到这个错误:
# rails c
FFI::NotFoundError: Function 'xmlRelaxNGSetParserStructuredErrors' not found in [libxml2.so, libxslt.so, libexslt.so]
attach_function at /home/prod/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/shared/ffi/library.rb:154
each at org/jruby/RubyArray.java:1612
attach_function at /home/prod/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/shared/ffi/library.rb:150
LibXML at /home/prod/.rvm/gems/jruby-1.6.5@p-ecom1-rails311/gems/nokogiri-1.4.6-java/lib/nokogiri/ffi/libxml.rb:305
Nokogiri at /home/prod/.rvm/gems/jruby-1.6.5@p-ecom1-rails311/gems/nokogiri-1.4.6-java/lib/nokogiri/ffi/libxml.rb:42
(root) at /home/prod/.rvm/gems/jruby-1.6.5@p-ecom1-rails311/gems/nokogiri-1.4.6-java/lib/nokogiri/ffi/libxml.rb:41
require at org/jruby/RubyKernel.java:1038
我让它在旧服务器上工作,但似乎在新服务器上缺少了一些东西。ruby和lib版本在两个服务器上似乎是相同的,即:
ruby -v => jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (OpenJDK 64位Server VM 1.6.0_20) [linux-amd64-java]
实际上-旧服务器上的java版本是Oracle版本…
Centos 5.7
# yum list | egrep "xslt|xml2"
libxml2.i386 2.6.26-2.1.12.el5_7.1 installed
libxml2.x86_64 2.6.26-2.1.12.el5_7.1 installed
libxml2-devel.i386 2.6.26-2.1.12.el5_7.1 installed
libxml2-devel.x86_64 2.6.26-2.1.12.el5_7.1 installed
libxml2-python.x86_64 2.6.26-2.1.12.el5_7.1 installed
libxslt.x86_64 1.1.17-2.el5_2.2 installed
libxslt-devel.x86_64 1.1.17-2.el5_2.2 installed
编辑:刚刚尝试了Oracle java版本来匹配旧的/working box,没有乐趣,虽然有稍微不同的错误,即:
$ ruby -v
jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) Server VM 1.6.0_29) [linux-i386-java]
$ rails c
LoadError: Could not open library 'xslt' : xslt: cannot open shared object file: No such file or directory. Could not open library 'libxslt.so' : libxslt.so: cannot open shared object file: No such file or directory
ffi_lib at /home/prod/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/shared/ffi/library.rb:82
collect at org/jruby/RubyArray.java:2318
EDIT2:
尝试更新mechanize和nokogiri,但似乎在mechanize 2中有cookie相关的差异-试图获得github版本,似乎应该解决这个问题。
EDIT3:
尝试1.4.7 Nokogiri,但仍然给出错误。现在我已经安装了1.5,它安装得很好,只是它在我的OSX开发环境中不起作用。可能需要提出nokogiri的错误-但必须编写一个测试程序来演示该问题
您通过FFI使用Nokogiri 1.4.6有什么原因吗?最新版本1.5.0采用纯Java风格,可能更适合您。
https://rubygems.org/gems/nokogiri/versions/1.5.0-java如果您的libxml2.so
中缺少该符号,则需要具有该符号的版本。在我的Mac上,我得到:
$ nm /usr/lib/libxml2.dylib | grep RelaxNGSetParserStructuredErrors
00000000000a5bcd T _xmlRelaxNGSetParserStructuredErrors