Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.3.18/ext/mysql2
/Users/username/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170727-92153-1wmtmv6.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.3.1/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.3.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
起こったこと
Ruby2.3.1でmysql2の0.3.18がインストールできなくなった
環境
原因
mysqlコマンドを使うためのPATHが通っていなかったため、MySQLのクライアントライブラリの検索に失敗していた
解決方法
.zshrcに以下を追記
参考URL
command not found
になったときの対処 - DailyHack http://ema-hiro.hatenablog.com/entry/20170406/1491490645エラーのログ
※ ユーザー名は適宜usernameに変更
bundle install時のエラー
メッセージの一番最後に書いてあるgem install mysql2 -v '0.3.18'を実行しても同じ内容のエラーが表示された
mkmf.logのログ
以下がおそらく原因となっている箇所
試してみたこと
オプションを付けてgem install
/usr/local/lib
にmysqlのコマンドが入っていないので効果なしRubyの2.3.1をアンインストールして再度インストール
PATHとは関係のないことなので効果なし
そもそもの疑問
疑問-1
疑問-2
疑問-3
command not found
が出たcommand not found
が出たので違いそう