jwi*_*x09 7 ruby macos gem nokogiri rvm
我知道这是一个在这里已经"解决"了很多次的问题,但我已经尝试了所有的解决方案,但仍然无法使其工作.这是我的错误:
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
Run Code Online (Sandbox Code Playgroud)
当我通过brew安装libxml2时:
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)
Run Code Online (Sandbox Code Playgroud)
和RVM:
22-01-14 17:57:56> rvm list
rvm rubies
=* ruby-2.1.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Run Code Online (Sandbox Code Playgroud)
和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
Run Code Online (Sandbox Code Playgroud)
我已尝试过这个和其他线程中的所有内容:" 在Ruby 2.0.0p353(基于rvm的安装)下安装Nokogiri 1.6.1失败(OSX Mavericks)? "
我甚至没有在我的Gemfile中定义Nokogiri.
好的,我找到了configure.log文件:
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
Run Code Online (Sandbox Code Playgroud)
在config.log中我发现:
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
Run Code Online (Sandbox Code Playgroud)
原来我没有正确引用C编译器.在我的".bash_profile"中,我有:
export CC=gcc-4.2.1
Run Code Online (Sandbox Code Playgroud)
我用以下代替:
export CC=gcc
Run Code Online (Sandbox Code Playgroud)