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

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

问题描述

我最近升级到10.10优胜美地测试版,但我在安装Nokogiri时遇到了麻烦。我正在使用RVM和Ruby 1.9.3。我也遵循了这里的步骤,并尝试遵循Nokogiri主页上的说明。

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

  gem install nokogiri -v'1.5.5'
构建原生扩展。这可能需要一段时间...
错误:安装nokogiri时出错:
错误:无法构建gem原生扩展。

/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
检查libxml / parser.h ... *** extconf .rb失败***
由于某种原因无法创建Makefile,可能缺少
必要的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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
- 与-pkg配置
--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':编译器无法生成可执行文件。 (RuntimeError)
您必须先安装开发工具。来自/ Users / grantdavis的/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:506:in`try_cpp'
中的
/.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:在`block in checking_for'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/ lib / ruby​​ / 1.9.1 / mkmf.rb:284:在`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:在`block in postpone'
from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:254:in`open'$ b / b from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:280:in`推迟'
from / Users / grantdavis / .rvm / rubies / ruby​​-1.9.3-p362 / lib / ruby​​ / 1.9.1 / mkmf.rb:789:在'checking_for'
from / Users / gra ntdavis / .rvm / rubies / ruby​​-1.9.3-p362 / lib / ruby​​ / 1.9.1 / mkmf.rb:969:在'find_header'中
from extconf.rb:114:在< main> '

任何人都有关于如何解决这些安装错误的想法?



编辑6/10/14:在OSX 10.10上安装Nokogiri几天后,我放弃了任务并在我的机器上恢复了10.9。为了在10.10环境中工作,需要更新几个库和包。

解决方案

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



第1步:安装Brew



如果安装了brew, p>

  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:下载并安装Apple Commandline Tools for 10.10



重要的是,您需要在安装后重新启动。

链接: command_line_tools_for_osx_10_10_june_2014.dmg



重新启动后,您可以检查Terminal中的安装:

 > ; xcode-select --install 
- > xcode-select:error:命令行工具已经安装,使用Software Update安装更新

这个错误意味着你有命令行工具正确安装。



安装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 / 


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.

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?

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.

解决方案

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

Step 1: Install Brew

Skip this if brew was installed.

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

Step 2: Install brew libs

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

Step 3: Download and install Apple Commandline Tools for 10.10

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

Link: 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.

Installing Nokogiri

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天全站免登陆