LoginSignup
5
4

More than 5 years have passed since last update.

bundle installでnokogiriのインストールが失敗する場合の解決方法

Last updated at Posted at 2015-07-21

エラー内容

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

参考

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4