Load Error Using Mechanize Gem

Hi,

I’m getting a “Could not open any of [xml2, xslt, exslt] (LoadError)”
error when trying to run a simple Ruby program taken from the
EXAMPLES.rdoc file of the Mechanize gem.

The error is in this line of the Nokogiri module of libxml.rb: ffi_lib
‘xml2’, ‘xslt’, ‘exslt’

Not sure if there are missing gems, and if so, what to install. Any
ideas how to fix this?

Thanks very much.

Gary M.

Program – main.rb:

Google

require ‘rubygems’
require ‘mechanize’

a = WWW::Mechanize.new { |agent|
agent.user_agent_alias = ‘Mac Safari’
}

a.get(‘http://google.com/’) do |page|
search_result = page.form_with(:name => ‘f’) do |search|
search.q = ‘Hello world’
end.submit

search_result.links.each do |link|
  puts link.text
end

end

Resources I’m using:

Editor: Netbeans IDE 6.7.1
Gems installed (among others): mechanize-0.9.3, nokogiri-1.3.3-java
Operating System: Windows Vista Home Premium, Service Pack 1, 64-Bit

Error message stack:

JRuby limited openssl loaded. gem install jruby-openssl for full
support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
C:/Program Files (x86)/NetBeans
6.7.1/ruby2/jruby-1.2.0/lib/ruby/1.8/ffi/library.rb:18:in ffi_lib': Could not open any of [xml2, xslt, exslt] (LoadError) from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokogiri/ffi/libxml.rb:5 from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokogiri/ffi/libxml.rb:31:in require’
from C:/Program Files (x86)/NetBeans
6.7.1/ruby2/jruby-1.2.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokogiri.rb:10 from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokogiri.rb:31:in require’
from C:/Program Files (x86)/NetBeans
6.7.1/ruby2/jruby-1.2.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize.rb:9 from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize.rb:31:in require’
from C:/Program Files (x86)/NetBeans
6.7.1/ruby2/jruby-1.2.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/mechanize.rb:7 from C:/Program Files (x86)/NetBeans 6.7.1/ruby2/jruby-1.2.0/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/mechanize.rb:36:in require’
from C:/Program Files (x86)/NetBeans
6.7.1/ruby2/jruby-1.2.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require’
from
C:\Users\Gary\Documents\NetBeansProjects\HTMLTextReplacement\lib\main.rb:5

Hi
I am assuming things here because you are on Jruby and windows

But you do require those libraries. Nokogiri in particular needs the
latest version of LibXml2 and you can run
nokogiri -v on your terminal to see if it has been built with the
latest version of libxml and the libxml2.dll is in the corrent load
path.

However I found this on the tenderlove wiki github its a known issue
and someone has sugested a workaround for windows:

http://github.com/tenderlove/nokogiri/issues/#issue/90

quote
"I solved the problem and record them here:

Make sure do not use libxml2 or libxslt, you should use libexslt. Good
luck.
"

I hope that helps