新手问题 gem install nokogiri 失败: Error installing nokogiri

zicjin · 2014年05月03日 · 最后由 liuxiang511240 回复于 2018年04月21日 · 11245 次阅读

在项目依赖capybara时需要nokogiri。安装过 libxml2 libxslt,也重装过ruby。不知道怎么办了。

cheneytekimbp:rails_projects zicjin$ sudo gem install nokogiri
Password:
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 extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26)...
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.
-----
*** 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
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-libxslt-config
    --without-libxslt-config
    --with-pkg-config
    --without-pkg-config
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-libiconv-config
    --without-libiconv-config
    --with-iconvlib
    --without-iconvlib
    --with-xml2lib
    --without-xml2lib

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
共收到 13 条回复
sudo apt-get install libxslt-dev libxml2-dev

#1楼 @Rei 我是mac brew install libxslt-dev libxml2-dev Error: No available formula for libxslt-dev

3楼 已删除

#2楼 @zicjin 错误提示你去看看 http://nokogiri.org/tutorials/installing_nokogiri.html 里面在Mac OSX一节有关于如何安装的介绍。

#2楼 @zicjin

Mac 应该用:

$ brew install libxml2 libxslt

#5楼 @huacnlee 都安装了,包括libiconv,是需要什么命令做一个激活么~~

sudo gem uninstall nokogiri

全选,Y确认卸载

sudo gem install nokogiri -- --use-system-libraries

我也遇到了这个问题,后代找到解决方案了么

@runup v1.6.8 has build problems, try following the issue: https://github.com/sparklemotion/nokogiri/issues/1483 若是本地development 开发几台的话可以试试: brew uninstall xz; gem install nokogirl -v 1.6.8

#10楼 @twairball 具体运行什么命令?

我也刚遇到 比较坑

2年了还是这么坑.. 😑

huacnlee 安装 Rails 失败,多次尝试未果 中提及了此贴 11月30日 10:22
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册