nokogiri无法安装osx

时间:2015-01-08 22:15:12

标签: ruby-on-rails macos bundler

我看到很多这类问题,但我的情况有点不同,所以我正在做bundle install并得到这个:

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/ gem installs ok但是我尝试捆绑我再次得到同样的错误同样的情况是当我尝试gem install nokogiri -v '1.6.5'时安装是好吧,我可以看到宝石列表中的宝石,但看起来像捆绑器没有看到它,我试图将它包含在我的宝石文件中,具有此特定版本但仍然有此错误

4 个答案:

答案 0 :(得分:9)

这对我有用:http://www.nokogiri.org/tutorials/installing_nokogiri.html#using_nonstandard_libxml2___libxslt_installations

gem install nokogiri -- \
    --use-system-libraries \
    --with-xml2-config=/usr/bin/xml2-config \
    --with-xslt-config=/usr/bin/xslt-config

然后bundle update

答案 1 :(得分:4)

您可以使用bundle config设置该路径:

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

答案 2 :(得分:4)

这对我有用bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"

运行此命令以在bundle install

之前设置配置

我从https://github.com/sparklemotion/nokogiri/issues/1099

获得了这个解决方案

答案 3 :(得分: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