Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

Red Hat / CentOS

The easiest way to get Nokogiri installed on CentOS and RHEL seems to be the EPEL repository which contains a prebuilt nokogiri package. To use it, install the appropriateepel-release package for your OS, then run:

sudo yum install -y rubygem-nokogiri

To install using gem install is somewhat more complicated because of the age of the packages available from the central repositories. If you have rubygems installed, you may be able to install nokogiri viagem install. If you run intro problems, try installing these packages as well.

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

CentOS 5 (and RHEL5) come installed with libxml 2.6.26 which, while not as offensively out-of-date as Mac Leopard, is still pretty damn old (released June 2006) and has known issues.

If you’re affected by any known bugs or are seeing odd behavior, you may want to consider uninstalling the RPMs for libxml2 and libxslt, and building them from source.

  1. sudo yum remove -y libxml2-devel libxslt-devel
  2. download the most recent libxml2 and libxslt from ftp://xmlsoft.org/libxml2/
  3. ./configure ; make ; sudo make install

Then install nokogiri specifying the libxml2 and libxslt install directories:

sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib 
                             --with-xml2-include=/usr/local/include/libxml2 
                             --with-xslt-lib=/usr/local/lib 
                             --with-xslt-include=/usr/local/include

(Note that, by default, libxslt header files are installed into the root include directory, but libxml2 header files are installed into a subdirectory thereof namedlibxml2.)

Or, you know, whatever directories into which you installed libxml and libxslt. Good luck.



http://nokogiri.org/tutorials/installing_nokogiri.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章