我最近升级到了优胜美地10.10测试版,但我在安装Nokogiri时遇到了麻烦.我正在使用RVM和Ruby 1.9.3.我也遵循了here个步骤,并try 按照Nokogiri主页上的说明进行操作.

我已经通过brew 软件安装了libxml2(2.9.1)和libxslt(1.1.28),并try 使用Xcode 5安装版和Xcode 6测试版中的命令行工具.

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:在try 了几天将Nokogiri安装到OSX 10.10上之后,我最终放弃了任务,在我的机器上恢复了10.9.为了在10.10环境中工作,需要更新几个库和Bundle 包.

推荐答案

我设法在优胜美地(OS X 10.10预览版)下安装了Nokogiri.

步骤1:安装Brew

如果安装了brew,请跳过此步骤.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

步骤2:安装brew libs

brew tap homebrew/dupes
brew install libxml2 libxslt
brew install libiconv

第3步:下载并安装Apple Commandline Tools for 10.10

安装后需要重新启动,这一点很重要.

链接: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

try 在Gemfile中使用以前的版本1.6.1,版本1.6.2.1当前存在"10.10预览"问题.它只适用于我的rbenv Ruby 2.0.0p247,未能在2.1.1上安装.您可以try 一下现有的Ruby版本.

gem install nokogiri  -v '1.6.1' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/

Ruby相关问答推荐

为什么在 Ruby 中将 0 视为 True?

由模块中定义的另一个覆盖方法

Windows 上的 Jekyll:Pygments 不工作

Ruby:如何判断字符是大写还是小写

Ruby 中是否有像 C 中一样的主要方法?

在 ruby​​ 中访问嵌套哈希的元素

进程的 pid、ppid、uid、euid、gid 和 egid 有什么区别?

将元素添加到 ruby​​ 数组返回新数组

如何让 Ruby 解析时间,就好像它在不同的时区一样?

`require': no such file to load in ruby

Sinatra 是多线程的吗?

用零填充数字

从 1 开始循环

在Ruby中实现平等的正确方法是什么

升级到 Rubygems 1.5.0 后,Bundler 抛出未初始化的常量 Gem::SilentUI (NameError) 错误

为什么显式返回会对 Proc 产生影响?

很好地格式化输出到控制台,指定选项卡的数量

将 CSV 文件转换为哈希数组

如何在 Ruby 中做标准差?

带有类名的动态类定义