# Load Error Using Mechanize Gem

**URL:** <https://www.ruby-forum.com/t/load-error-using-mechanize-gem/175664>\
**Category:** Rails\
**Created:** [September 17, 2009, 10:35am UTC](https://www.ruby-forum.com/t/load-error-using-mechanize-gem/175664 "2009-09-17T10:35:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Massing](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cdc98d/32.png) [@Gary\_Massing](https://www.ruby-forum.com/u/Gary_Massing)\
**Post date:** [September 17, 2009, 10:35am UTC](https://www.ruby-forum.com/t/load-error-using-mechanize-gem/175664/1 "2009-09-17T10:35:46Z")

</div>

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/](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](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

---

<div class="post-metadata">

**Author:** ![Gary\_Massing](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cdc98d/32.png) [@Gary\_Massing](https://www.ruby-forum.com/u/Gary_Massing)\
**Post date:** [September 17, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/load-error-using-mechanize-gem/175664/2 "2009-09-17T12:42:48Z")

</div>

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](http://github.com/tenderlove/nokogiri/issues/#issue/90)

quote  
"I solved the problem and record them here:

> **[Jruby 1.3.1 work with nokogiri 1.3.3](https://maodan520.wordpress.com/2009/08/17/jruby-1-3-1-work-with-nokogiri-1-3-3/)**
>
> I have same problem with FFI: Invalid callback paramete…

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

I hope that helps
