首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在OSX 10.9 Maverick上安装Nokogiri时出错?

在OSX 10.9 Maverick上安装Nokogiri时出错?
EN

Stack Overflow用户
提问于 2013-10-29 03:11:14
回答 26查看 53.3K关注 0票数 109

我把我的OSX (Lion)升级到了Mavericks,我不能在我的项目中安装Nokogiri。

我已经安装了XCode 5.0.1,命令行工具(使用xcode-select --install),并且已经从Homebrew安装了libxml2,但仍然有问题。

错误是:

代码语言:javascript
复制
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/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/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/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/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
    from extconf.rb:116:in `<main>'


Gem files will remain installed in /Users/ericcamalionte/Locaweb/code/dns-panel/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.9 for inspection.
Results logged to /Users/ericcamalionte/Locaweb/code/dns-panel/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.9), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.

我从Homebrew安装了libxml2,libxslt和libiconv,并设置了参数来安装Nokogiri,但也不能工作。

我找不到我周围的环境出了什么问题,你能帮我吗?

EN

回答 26

Stack Overflow用户

回答已采纳

发布于 2013-10-29 03:55:33

我找到这个日志,看到找不到gcc-4.2:

代码语言:javascript
复制
package configuration for libxslt
cflags: -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2
ldflags: -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib
libs: -lxslt -lxml2 -lz -lpthread -liconv -lm -lxml2

package configuration for libxml-2.0
cflags: -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2
ldflags: -L/usr/local/Cellar/libxml2/2.9.1/lib
libs: -lxml2

package configuration for libiconv is not found
"/usr/bin/gcc-4.2 -o conftest -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin11.4.0 -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2 -I/usr/local/Cellar/libiconv/1.14/include -I/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/include -I/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/include -I/Users/ericcamalionte/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE    -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DNOKOGIRI_USE_PACKAGED_LIBRARIES -DNOKOGIRI_LIBXML2_PATH='"/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0"' -DNOKOGIRI_LIBXSLT_PATH='"/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26"' -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2  -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2  conftest.c  -L. -L/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib -L/usr/local/Cellar/libiconv/1.14/lib -L/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/lib -L/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/lib -L/Users/ericcamalionte/.rvm/usr/lib -L.  -Wl,-rpath,/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/lib -Wl,-rpath,/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/lib -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib -L/usr/local/Cellar/libxml2/2.9.1/lib     -lxslt -lxml2 -lz -lpthread -liconv -lm -lxml2  -lxml2  -lruby.1.9.1-static  -lpthread -ldl -lobjc  "
sh: /usr/bin/gcc-4.2: No such file or directory
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

为了解决这个问题,我使用homebrew brew install apple-gcc42安装了apple-gcc42,并创建了一个指向我的/usr/bin的符号链接:

sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc-4.2

票数 20
EN

Stack Overflow用户

发布于 2014-02-13 13:45:06

在浏览了动画GIF here之后,我所要做的就是简单地使用xcode-select --installgem install nokogiri就可以正常工作了。

票数 30
EN

Stack Overflow用户

发布于 2014-03-28 11:56:06

如果您运行的是Xcode5.1,命令行工具不适用于nokogiri 1.6.1。您需要从Apple下载2013年10月底的工具。一旦你这样做了,运行

代码语言:javascript
复制
sudo xcode-select -s /Library/Developer/CommandLineTools/

要将计算机设置为使用Xcode 5.0.X命令行工具,请运行

代码语言:javascript
复制
gem install nokogiri

如果要在以后将命令行工具重置为Xcode.app版本,请运行

代码语言:javascript
复制
sudo xcode-select -r

或者,您可以做的另一件事是添加标志以忽略未知的命令行参数。然后安装看起来像这样:

代码语言:javascript
复制
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri
票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19643153

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档