nokogiri未能升级

时间:2015-05-24 15:29:35

标签: ruby gem nokogiri

有人见过这个吗?

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

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150524-28193-cqkmxr.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static

2 个答案:

答案 0 :(得分:47)

我刚刚在一个新的Ubuntu 14.04盒子上遇到了同样的问题,结果发现zlib源(即zlib.h)存在依赖关系,所以你需要:

在Ubuntu或Debian上:

sudo apt-get install zlib1g-dev

在Fedora,CentOS或RHEL上:

sudo yum install zlib-devel

或者找到适合您操作系统的等效包。

答案 1 :(得分:6)

您需要安装缺少的依赖项,例如:

sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev

然后再试一次:

gem install nokogiri