Help us understand the problem. What is going on with this article?

nokogiriのインストールエラーはXcode command line tools更新後に規約同意をしていないのが原因かも

More than 3 years have passed since last update.

ある時、Mac OS X Yosemite (10.10.5)でnokogiriのインストールに失敗しました。

ターミナル出力(後述)にはYou have to install development tools first.とあります。
つい最近までインストールできていたから開発環境が無いわけがないのに・・・と思っていたら、直前にXcode command line toolsの更新をしていたのが原因でした。規約同意していないのでxcodebuildが使えなかったんですね。

$ sudo xcodebuild -license
(中略)
By typing 'agree' you are agreeing to the terms of the software license agreements.
Type 'print' to print them or anything else to cancel, [agree, print, cancel] agree

これでインストールできるようになりました。

以下nokogiriインストール失敗時の出力

$ bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies........
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Installing nokogiri 1.6.7.1 with native extensions

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

    /Users/<user>/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151226-4433-1t2wmhu.rb extconf.rb --use-system-libraries
checking if the C compiler accepts ... *** 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/<user>/.rbenv/versions/2.2.3/bin/$(RUBY_BASE_NAME)
    --help
    --clean
/Users/<user>/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
    from /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
    from /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
    from extconf.rb:80:in `nokogiri_try_compile'
    from extconf.rb:87:in `block in add_cflags'
    from /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
    from extconf.rb:86:in `add_cflags'
    from extconf.rb:336:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.7.1 for inspection.
Results logged to /Users/<user>/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.7.1/gem_make.out
An error occurred while installing nokogiri (1.6.7.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.7.1'` succeeds before bundling.
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした