[英]Install Nokogiri 1.6.1 under Ruby 2.0.0p353 (rvm based installation) fails (OSX Mavericks)?
我試圖在Ruby和RVM下安裝Nokogiri 1.6.1,但是失敗了以下錯誤:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.0.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 /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... ERROR, review 'tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26/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/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:65:in `configure'
from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:108:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:131:in `call'
from extconf.rb:131:in `block in <main>'
from extconf.rb:122:in `tap'
from extconf.rb:122:in `<main>'
Gem files will remain installed in /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
檢查您的grep版本並安裝最新的brew brew:
$ grep --version
grep (BSD grep) 2.5.1-FreeBSD
$ brew install grep --default-names
# If above fails, you probably need to tap
$ brew tap homebrew/dupes
$ brew install grep --default-names
$ grep --version
grep (GNU grep) 2.14.56-1e3d
來自(這個nokogiri問題)[https://github.com/sparklemotion/nokogiri/issues/935]:“OSX的最新版本附帶BSD grep,而較舊版本附帶GNU grep。那么,你的構建腳本,也許需要GNU grep“
從Maverick的評論中被盜並在此復制作為答案,而不是評論,因為我現在已經多次遇到這個問題,並且希望能夠讓別人頭疼。 = X
您可以嘗試我到目前為止使用的解決方案來修復相同的...
刪除所有舊的libxml-ruby和nokogiri
使用下面的命令
sudo gem uninstall nokogiri libxml-ruby
然后你可以嘗試nokogiri的版本,有問題。 這應該是完美的。
sudo gem install nokogiri -v '1.6.1'
Dan報告了許多類似的答案,但有些變化。 謝謝。
我自己處理后就寫了這篇文章 。 不需要自制軟件。
我遇到了一些問題,第一個問題是無法找到開發工具,第二個問題是libxml太舊了。
在rubyconsole中運行以下命令:
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
$ gem uninstall nokogiri libxml-ruby
$ gem install nokogiri
原來有一個更簡單的解決方案:
刪除~/.bashrc
或~/.bash_profile
文件中的這一行:
GREP_OPTIONS="--color=always"
這一個:
export GREP_OPTIONS="--color=auto"
這樣您就不需要安裝任何重復項。 感謝MrPowers @ Nokogiri問題 。
手動./configure'include'和'lib'位置幫助我。 libxml2源代碼布局有點奇怪,所以我最終得到了類似的選項:
gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib
當然, 版本號取決於實際安裝的內容 。 在寫這篇文章的時候,那個版本正在釀造中。
在我的情況下/usr/local/Cellar/libxml2/2.9.1/include/libxml2
包含一個名為libxml
目錄和/usr/local/Cellar/libxml2/2.9.1/lib
包含libxml2.2.dylib libxml2.a libxml2.dylib pkgconfig xml2Conf.sh
:這些是腳本正在尋找的,沒有其他組合使它使用系統庫進行編譯。
使用homebrew nokogiri既可以安裝既不過時也不兼容(最近的)libxml2和libxslt庫,如本要點所述 。 為我工作得很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.