MySQLがbundle installできない!(Ruby on Rails)

MySQLがbundle installできない!(Ruby on Rails)

bundle install したときに mysql2 のところでエラーが出ました。

DS-MacBook-Air:rails_app daichisaito$ bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Fetching gem metadata from httpss://rubygems.org/………….
Fetching gem metadata from httpss://rubygems.org/..
Resolving dependencies…
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using mini_portile2 2.3.0
Using crass 1.0.4
Using rack 2.0.4
Using nio4r 2.3.0
Using websocket-extensions 0.1.3
Using mini_mime 1.0.0
Using arel 9.0.0
Using mimemagic 0.3.2
Using erubi 1.7.1
Using builder 3.2.3
Using bundler 1.16.1
Fetching byebug 10.0.2
Fetching bindex 0.5.0
Fetching msgpack 1.2.4
Installing bindex 0.5.0 with native extensions
Installing msgpack 1.2.4 with native extensions
Installing byebug 10.0.2 with native extensions
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching ffi 1.9.23
Installing ffi 1.9.23 with native extensions
Fetching multi_json 1.13.1
Installing multi_json 1.13.1
Fetching rb-fsevent 0.10.3
Installing rb-fsevent 0.10.3
Fetching ruby_dep 1.5.0
Installing ruby_dep 1.5.0
Using method_source 0.9.0
Fetching mysql2 0.5.1
Installing mysql2 0.5.1 with native extensions
Fetching puma 3.11.4
Installing puma 3.11.4 with native extensions
Using thor 0.20.0
Fetching tilt 2.0.8
Installing tilt 2.0.8
Using i18n 1.0.0
Using tzinfo 1.2.5
Using nokogiri 1.8.2
Using rack-test 1.0.0
Using sprockets 3.7.1
Using websocket-driver 0.7.0
Using mail 2.7.0
Using marcel 0.3.2
Fetching uglifier 4.1.9
Installing uglifier 4.1.9
Fetching bootsnap 1.3.0
Installing bootsnap 1.3.0 with native extensions
Fetching rb-inotify 0.9.10
Installing rb-inotify 0.9.10
Using activesupport 5.2.0
Using loofah 2.2.2
Fetching listen 3.1.5
Installing listen 3.1.5
Fetching sass-listen 4.0.0
Installing sass-listen 4.0.0
Using rails-dom-testing 2.0.3
Using rails-html-sanitizer 1.0.4
Using globalid 0.4.1
Using activemodel 5.2.0
Fetching jbuilder 2.7.0
Installing jbuilder 2.7.0
Fetching spring 2.0.2
Fetching sass 3.5.6
Using actionview 5.2.0
Using activejob 5.2.0
Using activerecord 5.2.0
Using actionpack 5.2.0
Using actioncable 5.2.0
Using actionmailer 5.2.0
Using activestorage 5.2.0
Using railties 5.2.0
Using sprockets-rails 3.2.1
Using rails 5.2.0
Fetching web-console 3.6.0
Installing spring 2.0.2
Installing web-console 3.6.0
Installing sass 3.5.6
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/daichisaito/Developing/RubyPractice/rails_app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.1/ext/mysql2
/Users/daichisaito/.rbenv/versions/2.5.0/bin/ruby -r
./siteconf20180415-39191-n8pajt.rb extconf.rb
checking for rb_absint_size()… yes
checking for rb_absint_singlebit_p()… yes

checking for rb_wait_for_single_fd()… yes

Using mysql_config at /usr/local/bin/mysql_config

checking for mysql.h… yes
checking for errmsg.h… yes
checking for SSL_MODE_DISABLED in mysql.h… yes
checking for SSL_MODE_PREFERRED in mysql.h… yes
checking for SSL_MODE_REQUIRED in mysql.h… yes
checking for SSL_MODE_VERIFY_CA in mysql.h… yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h… yes
checking for MYSQL.net.vio in mysql.h… yes
checking for MYSQL.net.pvio in mysql.h… no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h… yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h… yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h… yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h… yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h… yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h… yes

checking for my_bool in mysql.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.18_1/lib

creating Makefile

current directory:
/Users/daichisaito/Developing/RubyPractice/rails_app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.1/ext/mysql2
make “DESTDIR=” clean

current directory:
/Users/daichisaito/Developing/RubyPractice/rails_app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.1/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
/Users/daichisaito/Developing/RubyPractice/rails_app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.1
for inspection.
Results logged to
/Users/daichisaito/Developing/RubyPractice/rails_app/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/mysql2-0.5.1/gem_make.out

An error occurred while installing mysql2 (0.5.1), and Bundler cannot
continue.
Make sure that gem install mysql2 -v '0.5.1' succeeds before bundling.

In Gemfile:
mysql2

こちらを参考にしました。
httpss://qiita.com/akito19/items/e1dc54f907987e688cc0

$ bundle config –local build.mysql2 “–with-ldflags=-L/usr/local/opt/openssl/lib –with-cppflags=-I/usr/local/opt/openssl/include”

$ bundle install

で成功。

2018-05-20T17:35:09+00:00

About the Author:

齋藤大地
取締役。大手Sler出身。三度の飯よりコーディングが好きな人間。得意じゃないイラレやフォトショなどの仕事をしている時は目が死んでいる。使用言語は、Swift、Ruby(Ruby on Rails)、PHP、Javascript、Kotlin(ちょっとだけ)。

Leave A Comment

TWITTER

ご相談ください

 確認ページはございません。内容をご確認の上チェックを入れてください