こんなエラーが出た場合
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
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/5.7.16/lib
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.4/mkmf.log
current directory: /Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.4/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.4/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
①mysqlのバージョンを確認
$ mysql --version
②5.8系の場合
uninstallする
$ brew uninstall mysql
③mysql install mysql56を実行し5.6系をインストール
$ brew install mysql56
すでに入っていると言われたときは
$ brew reinstall mysql56
④一度linkを外す
$ brew unlink mysql@5.6
⑤再度linkをつなぎ直す
$ brew link --force mysql56
⑥再度bundle install
成功する!
これでも失敗した場合は↓↓↓↓
⑦アプリのディレクトリでmysql2をインストール
$ sudo gem install mysql2 -v ‘0.3.18’ --source ’https://rubygems.org/'
⑧bundle install
解決!