【问题标题】:Nokogiri does not install?Nokogiri 不安装?
【发布时间】:2013-10-18 08:16:50
【问题描述】:

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

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

但我宁愿解决它,因为每次我做一个捆绑时,它都会失败。问题来了:

$ 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

当我查看日志文件时:

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

有人知道怎么回事吗?

【问题讨论】:

  • 你知道一些聪明人发明了错误信息,我们必须学会尊重他们并开始阅读他们
  • 这是错误日志:configure: error: cannot find sources (entities.c) in /Volumes/Terra/Code/vimsource/vim/src or ..

标签: ruby nokogiri osx-mountain-lion libxml2


【解决方案1】:

在 Mavericks 中,首先使用 Homebrew 安装 gem 所依赖的库,然后在实际安装 gem 之前设置 NOKOGIRI_USE_SYSTEM_LIBRARIES=1 对我来说很有效。

总结:

  • 如果之前已安装,请卸载 gem:
    $ gem uninstall nokogiri

  • 使用 Homebrew 安装 libxml2libxsltlibiconv:
    $ 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"

gem 安装后bundle install应该没有错误完成。

【讨论】:

  • 我试过 $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install 而不是自己安装 gem,它对我有用。
【解决方案2】:

问题是 libxml2-2.8.0 没有正确安装。首先尝试安装它,然后安装 Nokogiri。

【讨论】:

  • 我已经 brew install libxml2 和 brew link libxml2 了。没有效果。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-02-14
  • 2016-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多