2013-07-28 112 views
4

我在安裝Nokogiri時遇到了問題。當我運行bundle installgem install nokogiri時,安裝失敗。爲什麼不安裝Nokogiri?

我得到的錯誤是: (注:此故障是使用上nokogiri.org安裝命令)

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

    /Users/roneesh/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib 
Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK 
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//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. 

我試圖使用的命令是:

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib 

我已經將brew,xml2,xslt和libiconv全部安裝好了,並放在上面的正確版本中。仍然沒有決議。我沒有做的唯一的事情是來自源代碼的libiconv(我的wget命令由於某種原因沒有工作)。

+0

你爲什麼要傳遞的所有這些選項:部份的圖書館對鏈接? –

+1

顯示'tmp // ports/libxml2/2.8.0/configure.log'的內容 –

回答

1

設置NOKOGIRI_USE_SYSTEM_LIBRARIES=1也爲我做了訣竅,但我必須安裝gem首先依賴的本地庫(我使用Homebrew完成),然後告訴gem使用它們。

彙總:

  • 如果以前安裝,卸載寶石:
    $ gem uninstall nokogiri

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

  • 安裝寶石指定pa
    $ 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"