エラー内容
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/sonixasia/.rbenv/versions/2.1.1/bin/ruby -r ./siteconf20150721-3619-114m9qd.rb extconf.rb --use-system-libraries
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 system libraries.
libxml2 version 2.6.21 or later is required!
*** 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.
解決方法
bundle config
コマンドで、nokogiriインストール時のオプションをセットします
$ bundle config build.nokogiri --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
~/.bundle/configが以下のようになっていることを確認します。
# ~/.bundle/config
---
BUNDLE_JOBS: '4'
BUNDLE_GEM__COC: '0'
BUNDLE_GEM__MIT: '0'
BUNDLE_GEM__TEST: 'false'
BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2"
この状態でbundle installすると成功しました。
$ bundle install