mysql2のインストール失敗 An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.

rails5をインストールするときにmysql2のgemがうまく入らずにハマった時のメモ

mac 10.12.3
ruby 2.3.1p112
Bundler version 1.12.5

```
Installing mysql2 0.4.5 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/ext/mysql2
/Users/yoshifuji.hiroki/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170415-12041-6ex24h.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
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 rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
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.6.26/lib
-----
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /workdir/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.5/mkmf.log

current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/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

make failed, exit code 2

Gem files will remain installed in /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5 for inspection.
Results logged to /workdir/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.5/gem_make.out
Using puma 3.8.2
Using bundler 1.12.5
Using sass 3.4.23
Using tilt 2.0.7
Using turbolinks-source 5.0.0
Using tzinfo 1.2.3
Using nokogiri 1.7.1
Using rack-test 0.6.3
Using sprockets 3.7.1
Using websocket-driver 0.6.5
Using mime-types 3.1
Using coffee-script 2.4.1
Using uglifier 3.2.0
Using rb-inotify 0.9.8
An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.5'` succeeds before bundling.
```

解決方法

xcode-select --install

xcodeのコマンドラインツールがインストールしてないだけだった。

xcodeのversionあげた場合とか気をつけたほうがよい。

0 件のコメント:

コメントを投稿

ReactNativeでAndroid対応する話

前提 ReactNativeでiOS版のアプリをリリースしていて、Android版をリリースする話 トラブルシューティング Build.VERSION_CODES.Q が存在しないエラー compileSdkVersionを29以上にすると解決 メモリー足りないエラー Execu...