7

I'm trying to install the Nokogiri gem under an RVM managed Ruby 1.8.7 installation in OS X Leopard (10.5.8).

I'm getting the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no
-----
The function 'xmlHasFeature' is missing from your installation of libxml2.  Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well.  To get around this problem, please upgrade your installation of libxml2.

Please visit http://nokogiri.org/tutorials/installing_nokogiri.html for more help!
*** extconf.rb failed ***

I have the latest libxml2 installed via homebrew (brew install libxml2), so I don't know what else to try.


Update:

I tried the instructions from the Nokogiri website and I can't get the Nokogiri gem installation to recognize libxml2.

Per the instructions I installed and linked libxml2 and libxslt via homebrew:

brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri

The error message has changed, but the Nokogiri installation complains that libxml2 is missing:

...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies

The installed libxml2 version is 2.7.8.


Update update:

I tried installing the iconv library from homebrew to see if I could solve the error checking for iconv_open() in iconv.h... no, so I ran the commands:

brew install libiconv
brew link libiconv

And after finishing the installation, I tried to install the nokogiri gem again, to get this error message, where the installer now complains that libiconv is missing

hecking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----

I'm clueless.

Community
  • 1
  • 1
bbonamin
  • 30,042
  • 7
  • 40
  • 49

3 Answers3

4

Per the directions at: http://nokogiri.org/tutorials/installing_nokogiri.html you needed to use:

brew install libxml2 libxslt
brew link libxml2 libxslt

then

gem install nokogiri

Did you use those or only brew install libxml2?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • thank you, I can't believe I missed such article in the official nokogiri page. I guess I haven't had any problems installing nokogiri in other platforms (or even OS X 10.6+), so I never needed it. I only installed the packages, but didn't link them; I'll try this solution and let you know what happens. – bbonamin Feb 17 '12 at 10:23
  • I added an update, following the instructions at the website I still can't get it installed – bbonamin Feb 23 '12 at 01:48
  • In the end I updated the OS X version and got everything working by standard means. – bbonamin Sep 07 '12 at 19:32
0

Make sure there is no Nokogiri version available:

use gem uninstall nokogiri

First install the command-line tool for Xcode. Refer to "How to use/install gcc on Mac OS X 10.8 / Xcode 4.4".

Then run the following commands:

brew install libxml2
gem install nokogiri

Now it works well, I tried it.

Community
  • 1
  • 1
Rameshwar Vyevhare
  • 2,699
  • 2
  • 28
  • 34
-1
brew install libxml2 libxslt
gem install nokogiri -- \
    --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.x/lib \
    --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.xx \
    --with-iconv-lib=/usr/lib \
    --with-iconv-include=/usr/local/include
Unihedron
  • 10,902
  • 13
  • 62
  • 72
FelipeSka
  • 1
  • 1
  • 2
    Please add some description to the code fragment you have provided so your answer makes more sense. – Zo Has Aug 12 '14 at 04:40