How to use nokogiri from Jruby on Windows?

前端 未结 3 1659
温柔的废话
温柔的废话 2021-01-25 04:12

I\'m getting the following error when trying to use Nokogiri with Jruby on Windows 7

D:\\code\\h4>jruby -e \"require \'rubygems\'; require \'nokogiri\'\"
D:/j         


        
相关标签:
3条回答
  • 2021-01-25 04:54

    There is now a pure Java version that can run on Windows as well.

    gem install nokogiri --pre
    

    Found here

    https://github.com/tenderlove/nokogiri/wiki/pure-java-nokogiri-for-jruby
    
    0 讨论(0)
  • 2021-01-25 04:57

    The workaround you found is for a UNIX system; the .so file is a loadable module, similar to a DLL in Windows. And you can't softlink in Windows (the ln -s command), so that doesn't apply in your situation.

    Nonetheless, you do have the same problem in that nokogiri can't find your libxml2, libxslt, & libexslt libraries. Since I don't use JRuby or nokogiri, I'm really not sure how it'll work, but my best guess is this:

    Most likely, you need Windows binaries (DLLs) of libxml2 and libxslt at a minimum; other related Windows binaries may be needed and are available at the same place. You'll want the DLLs installed somewhere in your path, or better yet in the same directory as your JRuby executable (looks like "D:/jruby-1.3.1/bin"). (If that doesn't work, perhaps a Java-native form of the libraries like libxmlj might work, but I doubt it--you probably need ones native to Windows.)

    I expect that will get you on your way to working.

    0 讨论(0)
  • 2021-01-25 05:11

    It is true that you need the xml2 / libxslt dlls in your path.

    However, I have found it necessary to update to jruby-1.4.0RC2 (for some FFI improvements I believe).

    Also, need to update to the latest nokogiri 1.3.3 & manually apply the following commit:

    http://github.com/tenderlove/nokogiri/commit/0555c69e70083a6368b563f18da2c8d5416515cc

    OR install nokogiri from github trunk.

    I hope this is helpful.

    Useful background links:

    • http://jira.codehaus.org/browse/JRUBY-3781
    • http://github.com/tenderlove/nokogiri/issues/closed/#issue/137
    • http://jira.codehaus.org/browse/JRUBY-4052
    • http://kenai.com/jira/browse/RUBY_FFI-46
    0 讨论(0)
提交回复
热议问题