我最近升级到了10.10 Yosemite测试版,但我在安装Nokogiri时遇到了麻烦。我使用的是RVM和Ruby 1.9.3。我也遵循了here的步骤,并尝试按照诺基里的主页上的说明进行操作。
我已经通过自制软件安装了libxml2 (2.9.1)和libxslt (1.1.28),并尝试使用我的Xcode5安装和Xcode6beta中的命令行工具。
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>'有谁知道如何修复这些安装错误?
EDIT 6/10/14:在尝试了几天在OSX10.10上安装Nokogiri之后,我最终放弃了这个任务,并在我的机器上恢复了10.9。为了在10.10环境中工作,需要更新一些库和包。
发布于 2014-06-11 06:01:06
我设法在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命令行工具
安装后需要重新启动,这一点很重要。
链接: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中使用n以前的版本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/发布于 2015-02-03 20:19:13
优胜美地中的libxml2 - 1.6.6.2:
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include发布于 2016-01-31 19:36:26
对于Mac OS El Capitan:
gem install nokogiri -v '1.6.7.1' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2
https://stackoverflow.com/questions/24091869
复制相似问题