2013-10-18 51 views
2

我似乎无法在我的Mac OS X 10.8系统上安装Nokogiri。我知道有一个解决方法,该解决方案和解决办法是: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/[email protected]/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/[email protected]/gems/mini_portile-0.5.1/lib/mini_portile.rb:243:in `chdir' 
    from /Users/buf/.rvm/gems/[email protected]/gems/mini_portile-0.5.1/lib/mini_portile.rb:243:in `execute' 
    from /Users/buf/.rvm/gems/[email protected]/gems/mini_portile-0.5.1/lib/mini_portile.rb:57:in `configure' 
    from /Users/buf/.rvm/gems/[email protected]/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/[email protected]/gems/nokogiri-1.6.0 for inspection. 
Results logged to /Users/buf/.rvm/gems/[email protected]/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 .. 

任何人都知道这是怎么回事?

+0

你知道,有些聪明人发明了错误信息,我们必须学会尊重他们,并开始阅读 – chirag7jain

+0

这是错误日志:配置:错误:无法找到/卷/泰/代码/ vimsource源(entities.c)/vim/src或.. – wiznaibus

+0

[在mac(libxml2)上安装nokogiri 1.6.0时出错的可能的重复](http://stackoverflow.com/questions/17863477/error-installing-nokogiri-1-6-0-on -mac-libxml2) – davidcondrey

回答

0

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

+0

我已经完成了brew install libxml2和brew链接libxml2。没有效果。 – wiznaibus

5

在小牛队中,使用Homebrew安装库,首先要依靠宝石,然后在实际安装宝石之前设置NOKOGIRI_USE_SYSTEM_LIBRARIES=1,这对我来说确实是个诀窍。

汇总:

  • 如果以前安装,卸载宝石:
    $ gem uninstall nokogiri

  • 使用自制安装libxml2libxsltlibiconv
    $ brew install libxml2 libxslt libiconv

  • 安装宝石指定pa创业板安装bundle install
    $ 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"

后应该没有错误完成:部份的图书馆对链接。

+0

我试过'$ NOKOGIRI_USE_SYSTEM_LIBRARIES = 1 bundle install',而不是自己安装gem,它对我很有用。 – Alessandro