2015-01-08 96 views
5

我看到了很多這樣的問題,但我有一點點不同的情況,所以我做bundle install並得到了這一點:引入nokogiri無法安裝OSX

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150109-25233-1jiriou.rb extconf.rb --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/ 
checking if the C compiler accepts ... yes 
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no 
Building nokogiri using packaged libraries. 
checking for iconv using --with-iconv-* flags... no 
checking for iconv... no 
----- 
libiconv is missing. Please locate mkmf.log to investigate how it is failing. 
----- 
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 
    --help 
    --clean 
    --use-system-libraries 
    --enable-static 
    --disable-static 
    --with-zlib-dir 
    --without-zlib-dir 
    --with-zlib-include 
    --without-zlib-include=${zlib-dir}/include 
    --with-zlib-lib 
    --without-zlib-lib=${zlib-dir}/lib 
    --enable-cross-build 
    --disable-cross-build 

extconf failed, exit code 1 

Gem files will remain installed in /var/folders/sk/x8m9btmj1g58c906v0z3k2br0000gq/T/bundler20150109-25233-o53u4y/nokogiri-1.6.5/gems/nokogiri-1.6.5 for inspection. 
Results logged to /var/folders/sk/x8m9btmj1g58c906v0z3k2br0000gq/T/bundler20150109-25233-o53u4y/nokogiri-1.6.5/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.5/gem_make.out 
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue. 
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling. 

我已經安裝了libiconv的,我在嘗試這種方式gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/寶石安裝好,但比我嘗試捆綁我再次得到了同樣的錯誤同樣的情況是當我試圖做​​3210安裝是好的,我可以看到寶石列表中的寶石,但似乎像捆綁器沒有看到它,我試圖把它包含在我的具有這個特定版本的寶石文件中,但仍然有這個錯誤

回答

4

您可以使用bundle config,以設置路徑:

bundle config build.nokogiri "--with-iconv-dir=/usr/local/Cellar/libiconv/1.14/" 
bundle install 
+1

這種解決方案我想這也是之前設置的配置,同樣的錯誤 – maki

+0

與cbertelegni的反應相結合這一點,它的工作! – Tiago

0

這個工作對我來說,這要歸功於Gergo & cbertelegni:

bundle config build.nokogiri "-- \ 
    --use-system-libraries \ 
    --with-xml2-config=/usr/bin/xml2-config \ 
    --with-xslt-config=/usr/bin/xslt-config" 
bundle install