Ran into an interesting problem today that took me a bit to figure out. I need to automate some web tasks so of course I turned to Mechanize. When trying to install the gem on Ubuntu I ran into the following problem:

io@crazo:~$ sudo gem install mechanize
Building native extensions.  This could take a while...
ERROR:  Error installing mechanize:
	ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install mechanize
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for exsltFuncRegister() in -lexslt... no
checking for libxml/xmlversion.h in /opt/local/include,/opt/local/include/libxml2,/usr/include/libxml2,/usr/include,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include,/opt/local/include/libxml2,/usr/include/libxml2,/usr/include,/usr/include/libxml2,/usr/local/include/libxml2... no
need libxslt
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/ruby1.8
	--with-xml2lib
	--without-xml2lib
	--with-xsltlib
	--without-xsltlib
	--with-exsltlib
	--without-exsltlib


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/nokogiri-1.1.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/nokogiri-1.1.0/ext/nokogiri/gem_make.out

This line threw a hint:
checking for libxslt/xslt.h in /opt/local/include,/opt/local/include/libxml2,/usr/include/libxml2,/usr/include,/usr/include/libxml2,/usr/local/include/libxml2… no

Anyways, after some Googling i found this post on Industry Zero and resolved the issue with a simple package installation:

io@crazo:~$ sudo apt-get install libxslt1-dev

After that, noooo problem installing mechanize and even resolved an issue i was having with nokogiri getting installed!

io@crazo:~$ sudo gem install mechanize
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.1.0
Successfully installed mechanize-0.9.0
2 gems installed
Installing ri documentation for nokogiri-1.1.0...
Installing ri documentation for mechanize-0.9.0...
Installing RDoc documentation for nokogiri-1.1.0...
Installing RDoc documentation for mechanize-0.9.0...