ども。意気揚々とbundle installしようとしたら出鼻をくじかれたどうも僕です。
深夜3時&酔っぱらいのテンションなのでブログのテンションがやばいですね。
さてブログタイトルのエラーが出たら、これまでの僕ならググってオラオラして解決するところですが、新生僕はちゃんとエラーログを読む男です(当たり前だ)
先輩たちがどうやってエラー解消しているか、横で一緒にやってもらって気づくこと
— Mayoi (@Mayoi_engineer) January 1, 2019
・エラーログを正しく読んでいる
・エラーが出ている以上、自分の書いたものを信用しない。該当箇所付近を一個ずつ読む
・ググっても公式ドキュメント。qiita等は例え話として参考にしてるだけ感
・どの言語かは無関係
please check the mkmf.log
こんなエラーログがでたので、最初gem install nokogiri -v '1.10.0' --source 'https://rubygems.org/'
だと思って頑張って叩いていた。
To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.10.0/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.0 for inspection. Results logged to /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.10.0/gem_make.out An error occurred while installing nokogiri (1.10.0), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.0' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.2, which depends on actioncable was resolved to 5.2.2, which depends on actionpack was resolved to 5.2.2, which depends on actionview was resolved to 5.2.2, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri
まてよ?
To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.10.0/mkmf.log
ここを読めよってすごい書いてある。
エラーログ読んでないってお前そういうとこだぞ。
というわけで開く。
mkmf.log
package configuration for libexslt is not found "clang -E -I/Users/ryo/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/ryo/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/ryo/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/Users/ryo/.rbenv/versions/2.5.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -o conftest.i" conftest.c:3:10: fatal error: 'libxml/xmlversion.h' file not found #include <libxml/xmlversion.h> ^~~~~~~~~~~~~~~~~~~~~ 1 error generated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <libxml/xmlversion.h> /* end */
ぱっと目につくpackage configuration for libexslt is not found
が原因そうですねー。
じゃあこれどうしたらええんや?
一番最初のエラーログを順に見ると
Results logged to /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.10.0/gem_make.out
とあるので、これを開いてみる。
gem_make.out
current directory: /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.0/ext/nokogiri /Users/ryo/.rbenv/versions/2.5.1/bin/ruby -I /Users/ryo/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190105-6585-szgbwp.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. pkg-config could not be used to find libxml-2.0 Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" pkg-config could not be used to find libxslt Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" pkg-config could not be used to find libexslt Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
gem install pkg-config -v "~> 1.1"
でインストールしてみたらよさそうですな。
% gem install pkg-config -v "~> 1.1" Fetching pkg-config-1.3.2.gem Successfully installed pkg-config-1.3.2 Parsing documentation for pkg-config-1.3.2 Installing ri documentation for pkg-config-1.3.2 Done installing documentation for pkg-config after 0 seconds 1 gem installed
前に進んだぞ。続けてさっきからコケてるbundle install
だ。
僕は無事成功した。自力でエラーログから解決できた。Googleなどいらぬ。
ところでおめぇmkmfって何か知ってっか?
mkmf.logということは、Makefileの生成に失敗する何かがあるってぇことでしょうね。