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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值