我最近升级到 10.10 Yosemite beta,但安装 Nokogiri 时遇到问题。我正在使用 RVM 和 Ruby 1.9.3。我也按照步骤操作here https://gist.github.com/vparihar01/5856524并尝试按照 Nokogiri 主页上的说明进行操作。
我已经通过自制程序安装了 libxml2 (2.9.1) 和 libxslt (1.1.28),并尝试使用 Xcode 5 安装和 Xcode 6 beta 中的命令行工具。
gem install nokogiri -v '1.5.5'
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
checking for libxml/parser.h... *** 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/grantdavis/.rvm/rubies/ruby-1.9.3-p362/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
from extconf.rb:114:in `<main>'
有人知道如何修复这些安装错误吗?
编辑 2014 年 6 月 10 日:在尝试了几天在 OSX 10.10 上安装 Nokogiri 后,我最终放弃了任务并在我的计算机上恢复了 10.9。为了在 10.10 环境中工作,需要更新多个库和捆绑包。
我成功地在 Yosemite(OS X 10.10 预览版)下安装了 Nokogiri。
第 1 步:安装 Brew
如果安装了brew,则跳过此步骤。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
第2步:安装brew库
brew tap homebrew/dupes
brew install libxml2 libxslt
brew install libiconv
步骤 3:下载并安装适用于 10.10 的 Apple 命令行工具
安装后需要重新启动,这一点很重要。
Link: command_line_tools_for_osx_10_10_june_2014.dmg http://adcdownload.apple.com/Developer_Tools/command_line_tools_os_x_10.10_for_xcode__june_2014/command_line_tools_for_osx_10_10_june_2014.dmg
重新启动后,您可以在终端中检查安装:
> xcode-select --install
-> xcode-select: error: command line tools are already installed, use "Software Update" to install updates
此错误表示您已正确安装命令行工具。
安装Nokogiri
尝试在 Gemfile 中使用以前的版本 1.6.1,版本 1.6.2.1 目前存在“10.10 预览版”问题。它仅适用于我的 rbenv Ruby 2.0.0p247,在 2.1.1 上安装失败。您可以尝试一下现有的 Ruby 版本。
gem install nokogiri -v '1.6.1' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)