雑なメモ
事象
$ bundle install
# 略
Installing nokogiri 1.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.1/ext/nokogiri
/Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/bin/ruby -r ./siteconf20181113-61284-1hjqgco.rb extconf.rb
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/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
--help
--clean
/Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/2.5.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/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:407:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/nokogiri-1.8.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /Users/yamakawa00/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/nokogiri-1.8.1/gem_make.out
An error occurred while installing nokogiri (1.8.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.1' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rails was resolved to 5.1.2, which depends on
actioncable was resolved to 5.1.2, which depends on
actionpack was resolved to 5.1.2, which depends on
actionview was resolved to 5.1.2, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
原因
ログの中身は以下の通り
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
Xcodeのライセンスを了承してねとのこと
解決策
$ sudo xcodebuild -license
# agreeと入力して完了