Ruby on Rails の開発環境を構築中
開発環境:
macOS Mojave $ ruby -v ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18] $ rbenv version 2.6.1 (set by /Users/username/.rbenv/version)
以下のコマンドを実行すると、、、
$ bundle install --path=vendor/bundle
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. になります(汗)
Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.3.2 Using concurrent-ruby 1.1.5 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.3 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Fetching nokogiri 1.10.3 Installing nokogiri 1.10.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/username/Develop/Ruby/myapp/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.3/ext/nokogiri /Users/username/.rbenv/versions/2.6.1/bin/ruby -I /Users/username/.rbenv/versions/2.6.1/lib/ruby/2.6.0 -r ./siteconf20190510-40753-10jfnoy.rb extconf.rb checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... *** 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/username/.rbenv/versions/2.6.1/bin/$(RUBY_BASE_NAME) --help --clean /Users/username/.rbenv/versions/2.6.1/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/username/.rbenv/versions/2.6.1/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile' from /Users/username/.rbenv/versions/2.6.1/lib/ruby/2.6.0/mkmf.rb:532:in `with_werror' from /Users/username/.rbenv/versions/2.6.1/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile' from extconf.rb:138:in `nokogiri_try_compile' from extconf.rb:162:in `block in add_cflags' from /Users/digi-angler/.rbenv/versions/2.6.1/lib/ruby/2.6.0/mkmf.rb:643:in `with_cflags' from extconf.rb:161:in `add_cflags' from extconf.rb:416:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/username/Develop/Ruby/myapp/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.10.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/username/Develop/Ruby/myapp/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.3 for inspection. Results logged to /Users/username/Develop/Ruby/myapp/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.10.3/gem_make.out An error occurred while installing nokogiri (1.10.3), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.3, which depends on actioncable was resolved to 5.2.3, which depends on actionpack was resolved to 5.2.3, which depends on actionview was resolved to 5.2.3, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri
mkmf.log
"clang -o conftest -I/Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0/x86_64-darwin18 -I/Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0/ruby/backward -I/Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0 -I. -I/Users/username/.rbenv/versions/2.6.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c -L. -L/Users/username/.rbenv/versions/2.6.1/lib -L. -L/Users/digi-angler/.rbenv/versions/2.6.1/lib -fstack-protector-strong -L/usr/local/lib -lruby.2.6-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc " In file included from conftest.c:1: In file included from /Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0/ruby.h:33: In file included from /Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0/ruby/ruby.h:29: /Users/username/.rbenv/versions/2.6.1/include/ruby-2.6.0/ruby/defines.h:123:10: fatal error: 'stdio.h' file not found #include <stdio.h> ^~~~~~~~~ 1 error generated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */
原因は何?
しばらくググって調べましたが、ネット上にある記事が古かったり、バージョンが違ったり、
やっていること(解決方法)が違ったり・・・
nokogiriがコンパイルに失敗して、
インストールも失敗しているんですかね・・・
ライブラリ(libxml2)が不足?しているんですかね?
解決方法をご教授願います。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/10 12:10