Ruby 2.1和Nokogiri安装错误? [英] Ruby 2.1 and Nokogiri install error?

查看:127
本文介绍了Ruby 2.1和Nokogiri安装错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个在这里已经解决很多次的问题,但我尝试了所有的解决方案,但仍然无法实现。这是我的错误:

  22-01-14 17:57:56> gem install nokogiri 
构建原生扩展。这可能需要一段时间...
错误:安装nokogiri时出错:
错误:无法构建gem本机扩展。

/Users/josh/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
将libxml2-2.8.0.tar.gz提取到tmp // ports / libxml2 / 2.8.0 ... OK
为libxml2 2.8.0 ...运行'configure'...错误,查看'tmp // ports / libxml2 / 2.8.0 / configure.log'来查看发生了什么。
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--with-opt-dir
--without-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 / josh / .rvm / rubies / ruby​​-2.1.0 / bin / ruby​​
/Users/josh/.rvm/gems/ruby- 2.1.0 / gems / mini_portile-0.5.2 / lib / mini_portile.rb:265:在`block in execute'中:无法完成配置任务(RuntimeError)
来自/Users/josh/.rvm/gems/ ruby-2.1.0 / gems / mini_portile-0.5.2 / lib / mini_portile.rb:257:来自/Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile的`chdir'
-0.5.2 / lib / mini_portile.rb:257:在/ execute / josh / rb:65:在`configure'
从/Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:108:in`cook'$来自extconf.rb的b $ b:101:在< main>块中的
:来自extconf.rb的
:119:在'call'中
来自extconf.rb:119:在< block ;主要>'来自extconf.rb的
:109:来自'tap'的
来自extconf.rb的
:109:< main>'

extconf失败, 1

Gem文件将保持安装在/ Users / josh /中。 rvm / gems / ruby​​-2.1.0 / gems / nokogiri-1.6.1进行检查。
记录到/Users/josh/.rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/nokogiri-1.6.1/gem_make.out
的结果

当我通过brew安装libxml2时:

  22-01-14 17:57:56> brew列表
ab cmake freetype gettext jpeg libksba libvo-aacenc lzlib openjpeg proj speex xvid
apple-gcc42 elasticsearch freexl giflib json-c liblwgeom libvorbis memcached openssl qt sqlite xz
apr faac frei0r git lame libogg libvpx mongodb opus readline texi2html yasm
apr-util fdk-aac fribidi gpp libass libpng libxml2 mysql orc redis theora
autoconf ffmpeg gd graphviz libevent libspatialite libxslt node pcre rtmpdump ttfautohint
automake fontconfig gdal grep libgeotiff libtiff libyaml openconnect phantomjs schroedinger wkhtmltopdf
cloc fontforge geos imagemagick libgpg-error libtool little-cms2 opencore-amr pkg-config sdl x264

22-01-14 17:57:56> brew列表libxml2
/usr/local/Cellar/libxml2/2.8.0/bin/xmllint
/usr/local/Cellar/libxml2/2.8.0/bin/xmlcatalog
/ usr / local / Cellar / libxml2 / 2.8.0 / bin / xml2-config
/usr/local/Cellar/libxml2/2.8.0/include/libxml2/(47个文件)
/ usr / local / Cellar /libxml2/2.8.0/lib/libxml2.2.dylib
/usr/local/Cellar/libxml2/2.8.0/lib/pkgconfig/libxml-2.0.pc
/ usr / local / Cellar /libxml2/2.8.0/lib/(3个其他文件)
/usr/local/Cellar/libxml2/2.8.0/share/aclocal/libxml.m4
/ usr / local / Cellar / libxml2 /2.8.0/share/doc/(121个文件)
/usr/local/Cellar/libxml2/2.8.0/share/gtk-doc/(55个文件)
/ usr / local / Cellar /libxml2/2.8.0/share/man/(4个文件)

和RVM:

  22-01-14 17:57:56> rvm list 

rvm rubies

= * ruby​​-2.1.0 [x86_64]

#=> - 当前
#= * - 当前&&默认
#* - 默认

和GCC:

  22-01-14 17:57:56> gcc --version 
配置:--prefix = / Applications / Xcode.app /目录/ Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
苹果LLVM版本5.0(clang-500.2.79)(基于LLVM 3.3svn)
目标:x86_64-apple-darwin13.0.2
线程模型:posix

我已经尝试过所有这些和其他线程:
在Ruby 2.0.0p353(基于rvm的安装)下安装Nokogiri 1.6.1失败(OSX小牛)?



另外我甚至没有在Gemfile中定义Nokogiri。






好的,我找到了configure.log文件:

  1检查编译系统键入... i386-apple-darwin13.0.2 
检查主机系统类型... i386-apple-darwin13.0.2
检查BSD兼容安装... / usr / bin /安装-c
4检查构建环境是否为s ane ... yes
5检查线程安全的mkdir -p ... ./install-sh -c -d
6检查gawk ... no
7检查mawk ... no
8检查nawk ... no
9检查awk ... awk
10检查make sets $(MAKE)... yes
11检查gcc ... gcc-4.2.1
12检查C编译器是否工作... no
13 configure:error:in`/Users/josh/.rvm/gems/ruby- 2.1.0 / gems / nokogiri-1.6.1 / ext / nokogiri / tmp / ports / libxml2 / 2.8.0 / libxml2-2.8.0':
14 configure:error:C编译器无法创建可执行文件
15查看`config.log'获取更多细节

在config.log中,我发现:

  83 configure:3326:检查C编译器版本
84 configure:3335:gcc-4.2.1 --version >& 5
85 configure:line 3337:gcc-4.2.1:command not found
86 configure:3346:$? = 127
87 configure:3335:gcc-4.2.1 -v>& 5
88 configure:line 3337:gcc-4.2.1:command not found
89 configure:3346 :$? = 127
90配置:3335:gcc-4.2.1 -V>& 5
91配置:行3337:gcc-4.2.1:找不到命令
92 configure:3346 :$? = 127
93 configure:3335:gcc-4.2.1 -qversion>& 5
94配置:行3337:gcc-4.2.1:找不到命令
95 configure:3346 :$? = 127
96 configure:3366:检查C编译器是否工作
97 configure:3388:gcc-4.2.1 conftest.c>& 5
98 configure:line 3390:gcc -4.2.1:找不到命令


解决方案

我没有正确引用C编译器。在我的.bash_profile中有:

  export CC = gcc-4.2.1 

pre
$ p $

出口CC = gcc


I know this is an issue that has been "solved" many times here, but I have tried all of the solutions and still can't get it to work. Here is my error:

22-01-14 17:57:56> gem install nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.

/Users/josh/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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
  --without-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/josh/.rvm/rubies/ruby-2.1.0/bin/ruby
    /Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete configure task (RuntimeError)
  from /Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
  from /Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
  from /Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:65:in `configure'
  from /Users/josh/.rvm/gems/ruby-2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:108:in `cook'
  from extconf.rb:101:in `block in <main>'
  from extconf.rb:119:in `call'
  from extconf.rb:119:in `block in <main>'
  from extconf.rb:109:in `tap'
  from extconf.rb:109:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/josh/.rvm/gems/ruby-2.1.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/josh/.rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/nokogiri-1.6.1/gem_make.out

When I have libxml2 installed via brew:

22-01-14 17:57:56> brew list
ab      cmake       freetype    gettext     jpeg        libksba     libvo-aacenc    lzlib       openjpeg    proj        speex       xvid
apple-gcc42 elasticsearch   freexl      giflib      json-c      liblwgeom   libvorbis   memcached   openssl     qt      sqlite      xz
apr     faac        frei0r      git     lame        libogg      libvpx      mongodb     opus        readline    texi2html   yasm
apr-util    fdk-aac     fribidi     gpp     libass      libpng      libxml2     mysql       orc     redis       theora
autoconf    ffmpeg      gd      graphviz    libevent    libspatialite   libxslt     node        pcre        rtmpdump    ttfautohint
automake    fontconfig  gdal        grep        libgeotiff  libtiff     libyaml     openconnect phantomjs   schroedinger    wkhtmltopdf
cloc        fontforge   geos        imagemagick libgpg-error    libtool     little-cms2 opencore-amr    pkg-config  sdl     x264

22-01-14 17:57:56> brew list libxml2
/usr/local/Cellar/libxml2/2.8.0/bin/xmllint
/usr/local/Cellar/libxml2/2.8.0/bin/xmlcatalog
/usr/local/Cellar/libxml2/2.8.0/bin/xml2-config
/usr/local/Cellar/libxml2/2.8.0/include/libxml2/ (47 files)
/usr/local/Cellar/libxml2/2.8.0/lib/libxml2.2.dylib
/usr/local/Cellar/libxml2/2.8.0/lib/pkgconfig/libxml-2.0.pc
/usr/local/Cellar/libxml2/2.8.0/lib/ (3 other files)
/usr/local/Cellar/libxml2/2.8.0/share/aclocal/libxml.m4
/usr/local/Cellar/libxml2/2.8.0/share/doc/ (121 files)
/usr/local/Cellar/libxml2/2.8.0/share/gtk-doc/ (55 files)
/usr/local/Cellar/libxml2/2.8.0/share/man/ (4 files)

and RVM:

22-01-14 17:57:56> rvm list

rvm rubies

=* ruby-2.1.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

and GCC:

22-01-14 17:57:56> gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.2
Thread model: posix

I have tried everything in this and other threads: "Install Nokogiri 1.6.1 under Ruby 2.0.0p353 (rvm based installation) fails (OSX Mavericks)?"

Also I don't even have Nokogiri defined in my Gemfile.


OK, I found the configure.log file:

  1 checking build system type... i386-apple-darwin13.0.2
  2 checking host system type... i386-apple-darwin13.0.2
  3 checking for a BSD-compatible install... /usr/bin/install -c
  4 checking whether build environment is sane... yes
  5 checking for a thread-safe mkdir -p... ./install-sh -c -d
  6 checking for gawk... no
  7 checking for mawk... no
  8 checking for nawk... no
  9 checking for awk... awk
 10 checking whether make sets $(MAKE)... yes
 11 checking for gcc... gcc-4.2.1
 12 checking whether the C compiler works... no
 13 configure: error: in `/Users/josh/.rvm/gems/ruby-2.1.0/gems/nokogiri-1.6.1/ext/nokogiri/tmp/ports/libxml2/2.8.0/libxml2-2.8.0':
 14 configure: error: C compiler cannot create executables
 15 See `config.log' for more details

And in the config.log I found:

83 configure:3326: checking for C compiler version
84 configure:3335: gcc-4.2.1 --version >&5
85 configure: line 3337: gcc-4.2.1: command not found
86 configure:3346: $? = 127
87 configure:3335: gcc-4.2.1 -v >&5
88 configure: line 3337: gcc-4.2.1: command not found
89 configure:3346: $? = 127
90 configure:3335: gcc-4.2.1 -V >&5
91 configure: line 3337: gcc-4.2.1: command not found
92 configure:3346: $? = 127
93 configure:3335: gcc-4.2.1 -qversion >&5
94 configure: line 3337: gcc-4.2.1: command not found
95 configure:3346: $? = 127
96 configure:3366: checking whether the C compiler works
97 configure:3388: gcc-4.2.1    conftest.c  >&5
98 configure: line 3390: gcc-4.2.1: command not found

解决方案

It turned out I wasn't referencing the C compiler properly. In my ".bash_profile" I had:

export CC=gcc-4.2.1

And I replaced it with:

export CC=gcc

这篇关于Ruby 2.1和Nokogiri安装错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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