在 OSX 10.10 Yosemite 上安装 Nokogiri [英] Installing Nokogiri on OSX 10.10 Yosemite

查看:16
本文介绍了在 OSX 10.10 Yosemite 上安装 Nokogiri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 10.10 Yosemite 测试版,但在安装 Nokogiri 时遇到了问题.我正在使用 RVM 和 Ruby 1.9.3.我还按照此处的步骤操作,并尝试按照 Nokogiri 主页上的说明进行操作.

I recently upgrade to the 10.10 Yosemite beta, but I'm having trouble getting Nokogiri installed. I'm using RVM and Ruby 1.9.3. I've also followed the steps here and tried following the instructions on Nokogiri's homepage.

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

I've installed libxml2 (2.9.1) and libxslt (1.1.28) via homebrew, and have tried using the command line tools from both my Xcode 5 install and 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>'

有人知道如何解决这些安装错误吗?

Anyone have an idea on how to fix these install errors?

编辑 6/10/14: 在尝试了几天在 OSX 10.10 上安装 Nokogiri 之后,我最终放弃了任务并在我的机器上恢复了 10.9.一些库和捆绑包需要更新才能在 10.10 环境中工作.

EDIT 6/10/14: After trying for a couple days to get Nokogiri installed on OSX 10.10, I ended up abandoning the task and restored 10.9 on my machine. Several libraries and bundles need to be updated in order to work in the 10.10 environment.

推荐答案

我设法在 Yosemite (OS X 10.10 Preview) 下安装了 Nokogiri.

I managed to install Nokogiri under Yosemite (OS X 10.10 Preview).

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

Skip this if brew was installed.

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 命令行工具

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

Step 3: Download and install Apple Commandline Tools for 10.10

It's important that you need to restart after installation.

链接:command_line_tools_for_osx_10_10_june_2014.dmg

重启后可以在终端查看安装:

After restarted, you can check installation in Terminal:

> xcode-select --install
-> xcode-select: error: command line tools are already installed, use "Software Update" to install updates

此错误表示您已正确安装命令行工具.

This error means you have commandline tool installed correctly.

尝试在您的 Gemfile 中使用 n 个以前的 1.6.1 版本,版本 1.6.2.1 目前存在10.10 预览版"的问题.它仅适用于我的 rbenv Ruby 2.0.0p247,无法在 2.1.1 上安装.您可以尝试一下现有的 Ruby 版本.

Try using n previous version 1.6.1 in your Gemfile, version 1.6.2.1 has issues currently with "10.10 Preview". It only works with my rbenv Ruby 2.0.0p247, failed to install on 2.1.1. You can give your existing Ruby versions a couple of tries.

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

这篇关于在 OSX 10.10 Yosemite 上安装 Nokogiri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆