在OS X 10.10优胜美地没有安装的宝石安装nokogiri -v'1.6.3.1'

时间:2014-10-29 13:20:45

标签: ruby macos nokogiri osx-yosemite

更新到OS X 10.10 Yosemite后我无法安装nokogiri(1.6.3.1)

> bundle

Building nokogiri using packaged libraries.

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

    /Users/ju/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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/ju/.rvm/rubies/ruby-2.1.2/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 /Users/ju/.rvm/gems/ruby-2.1.2@sumup/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/ju/.rvm/gems/ruby-2.1.2@sumup/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

4 个答案:

答案 0 :(得分:8)

> brew update
> brew install libxml2 libxslt libiconv

> brew --prefix libxml2
/usr/local/opt/libxml2

> brew --prefix libxslt
/usr/local/opt/libxslt

> brew --prefix libiconv
/usr/local/opt/libiconv

> gem uninstall nokogiri

> gem install nokogiri -v 1.6.3.1 -- --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config

基于:Mac fix 1 - Install the Nokogiri gem on Mac OS 10.9 Mavericks

其他解决方案:

> gem install nokogiri -v 1.6.3.1 -- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2/

评论的另一个解决方案:

> xcode-select --install gem install nokogiri

答案 1 :(得分:4)

以下在优胜美地10.10.3上为我工作:

sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries

取自Nokogiri issues tracker

答案 2 :(得分:0)

  

brew更新   brew install libxml2 libxslt libiconv

     

brew --prefix libxml2   的/ usr /本地的/ opt / libxml2的

     

brew --prefix libxslt   的/ usr /本地的/ opt /的libxslt

     

brew --prefix libiconv   的/ usr /本地的/ opt / libiconv的

     

gem uninstall nokogiri

     

gem install nokogiri -v 1.6.3.1 - --with-xslt-dir = / usr / local / opt / libxslt --with-iconv-dir = / usr / local / opt / libiconv --with-xml2 -config = / usr / local / opt / libxml2 / bin / xml2-config --with-xslt-config = / usr / local / opt / libxslt / bin / xslt-config

答案 3 :(得分:0)

如果您使用 bundle install --path vendor/bundle 将 gems 安装到本地文件夹并出现错误

Building nokogiri using packaged libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

然后,您需要执行以下操作

bundle config build.nokogiri --use-system-libraries
bundle install --path vendor/bundle

然后安装会通过

Fetching nokogiri 1.6.3.1
Installing nokogiri 1.6.3.1 with native extensions
Building nokogiri using system libraries.