Nokogiri没有安装?

wiz*_*bus 2 ruby libxml2 nokogiri osx-mountain-lion

我似乎无法在我的Mac OS X 10.8系统上安装Nokogiri.我知道这个解决方案有一个解决方法,解决方法是:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install
Run Code Online (Sandbox Code Playgroud)

但我宁愿解决它,因为每次我做一个捆绑,它都会失败.这是问题所在:

$ gem install nokogiri

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

    /Users/buf/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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
  --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=/Users/buf/.rvm/rubies/ruby-2.0.0-p195/bin/ruby
/Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/mini_portile-0.5.1/lib/mini_portile.rb:251:in `block in execute': Failed to complete configure task (RuntimeError)
  from /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/mini_portile-0.5.1/lib/mini_portile.rb:243:in `chdir'
  from /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/mini_portile-0.5.1/lib/mini_portile.rb:243:in `execute'
  from /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/mini_portile-0.5.1/lib/mini_portile.rb:57:in `configure'
  from /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/mini_portile-0.5.1/lib/mini_portile.rb:100:in `cook'
  from extconf.rb:101:in `block in <main>'
  from extconf.rb:119:in `call'
  from extconf.rb:119:in `block in <main>'
  from extconf.rb:109:in `tap'
  from extconf.rb:109:in `<main>'


Gem files will remain installed in /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/buf/.rvm/gems/ruby-2.0.0-p195@rentify193/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
Run Code Online (Sandbox Code Playgroud)

当我查看日志文件时:

configure: error: cannot find sources (entities.c) in /Volumes/Terra/Code/vimsource/vim/src or ..
Run Code Online (Sandbox Code Playgroud)

有谁知道发生了什么?

Edu*_*rdo 5

在Mavericks中,使用Homebrew安装库,gem首先依赖,然后NOKOGIRI_USE_SYSTEM_LIBRARIES=1在实际安装gem之前进行设置对我来说是个窍门.

总结:

  • 如果以前安装过,请卸载gem:
    $ gem uninstall nokogiri

  • 使用Homebrew进行安装libxml2,libxslt并且libiconv:
    $ brew install libxml2 libxslt libiconv

  • 安装gem指定要链接的库的路径:
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

安装宝石后bundle install应完成没有错误.