Ruby 在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测试版中的命令行工具Ruby 在OSX 10.10 Yosemite上安装Nokogiri,ruby,gem,bundler,nokogiri,homebrew,Ruby,Gem,Bundler,Nokogiri,Homebrew,我最近升级到了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' Building native extensions. This could take a
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>'
gem安装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文件了解更多信息
细节。您可能需要配置选项。
提供的配置选项:
--使用opt dir
--选择包含
--不带opt include=${opt dir}/include
--使用opt lib
--不带opt lib=${opt dir}/lib
--用make prog
--没有make prog
--srcdir=。
--库尔迪尔
--ruby=/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/bin/ruby
--使用zlib dir
--没有zlib dir
--与zlib一起包括
--没有zlib include=${zlib dir}/include
--使用zlib库
--没有zlib lib=${zlib dir}/lib
--使用iconv dir
--没有iconv目录
--与iconv包括
--不带iconv include=${iconv dir}/include
--使用iconv库
--不带iconv lib=${iconv dir}/lib
--with-xml2-dir
--不带-xml2-dir
--with-xml2-include
--不带-xml2-include=${xml2 dir}/include
--with-xml2-lib
--不带-xml2-lib=${xml2 dir}/lib
--使用xslt-dir
--没有xslt目录
--使用xslt包括
--不带xslt include=${xslt dir}/include
--使用xslt库
--不带xslt lib=${xslt dir}/lib
--使用libxslt配置
--没有libxslt配置
--使用pkg配置
--没有pkg配置
--with-libxml-2.0-config
--不带-libxml-2.0-config
--使用libiconv配置
--没有libiconv配置
/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:381:在“try_do”中:编译器未能生成可执行文件。(运行时错误)
您必须首先安装开发工具。
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:“查找头中的块”
from/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:790:in“块入检查”
from/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:284:in“延迟中的块(2层)”中
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“延迟中的块”
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“推迟”
from/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:789:in'checking_'
from/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:969:in'find_header'
来自extconf.rb:114:in`'
有人知道如何修复这些安装错误吗
编辑6/10/14:在尝试了几天将Nokogiri安装到OSX 10.10上之后,我最终放弃了任务,在我的机器上恢复了10.9。要在10.10环境中工作,需要更新多个库和捆绑包。请尝试以下方法:
按给定顺序安装这些软件包:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
尝试更新gcc版本:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
步骤2:安装brew libs
步骤3:下载并安装适用于10.10的Apple命令行工具
安装后需要重新启动,这一点很重要
链接:
重新启动后,您可以在终端中检查安装:
> xcode-select --install
-> xcode-select: error: command line tools are already installed, use "Software Update" to install updates
此错误意味着您已正确安装命令行工具
安装Nokogiri
尝试在您的GEM文件中使用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/
我认为问题与系统Ruby找不到或安装了多个Ruby有关
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 您是否使用RVM管理红宝石
- ruby-v的输出是什么
错误解释器
错误与Ruby安装问题有关
理想情况下,您应该从系统Ruby开始,即Xcode附带的系统。
因此,您可以使用以下方法完全卸载Xcode:
卸载brew
,rvm
,然后重新安装。(此处有完整答案)
看起来自制软件在某种程度上依赖于Ruby的1.8版(尽管Mavericks也提供了2.0版)。在Homebrew解决这个问题之前,我们将把我们的Ruby系统版本与Homebrew寻找的版本进行符号链接
创建文件夹:
sudo mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
然后对二进制文件进行符号链接:
sudo ln -s /usr/bin/ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
我对MacPorts ruby2.1也有同样的问题:
can not gem install nokogiri on osx10.10 with macports ruby2.1
安装开始时,单核上的cpu在100%时达到50%,然后cpu降至接近零,但是iostat tps
会穿墙而过
这有助于:
# port install libiconv libxslt libxml2
# gem install nokogiri -- --use-system-libraries --with-iconv-dir=/opt/local --with-xml2-dir=/opt/local --with-xslt-dir=/opt/local
来自OSX 10.9和10.10的说明对我都有效
brew unlink gcc-4.2 # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
这对我很有用:
ARCHFLAGS="-arch x86_64" gem install nokogiri -v '1.6.0'
sudo gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
$ brew install libxml2 libxslt # optional?
$ brew install libiconv # optional?
$ gem install nokogiri -v 1.6.8 -- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2
对于我来说,切换到Xcode 5而不是使用Xcode 6的CLI工具:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
唯一对我有用的是将编译器从apple-gcc42升级到gcc48:
brew uninstall apple-gcc42
brew install gcc48 # this might take an hour or so
rvm implode
\curl -sSL https://get.rvm.io | bash -s stable # reinstall RVM
rvm install ruby-1.9.3-p551
bundle update libv8 # 3.16.14.3 doesn't work but 3.16.14.7 does
bundle
libxml2-
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"
export NOKOGIRI_USE_SYSTEM_LIBRARIES=Y
gem install nokogiri
...
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
...
gem install nokogiri -- --use-system-libraries --with-libxml2lib=/usr/local/opt/libxml2/lib/libxml2.a
sudo gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
sudo gem update --system
sudo gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
sudo xcodebuild -license
$ brew install libxml2 libxslt # optional?
$ brew install libiconv # optional?
$ gem install nokogiri -v 1.6.8 -- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2
$ sw_vers -productVersion
10.9.4
$ brew -v
Homebrew 0.9.9 (git revision aa747; last commit 2016-05-26)
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]
sudo gem install nokogiri -n /usr/local/bin
sudo gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config
xcode-select --install