27歳未経験でエンジニア転職した元営業マン

アルバイトで半年間をドブに捨てた後、2ヶ月でエンジニア転職した記録

HombrewでmysqlをMacにインストールする

解決策

myslqが入っていなかったので、hombrewでmysqlをインストールする ※hombrewがインストールされている前提

$ brew update
$ brew install mysql

参考にしたサイト

https://qiita.com/griffin3104/items/c7908359a3e3e18cd269

エラー内容

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

    current directory: /Users/tomohiro/.rvm/gems/ruby-2.5.1/gems/mysql2-0.5.2/ext/mysql2
/Users/tomohiro/.rvm/rubies/ruby-2.5.1/bin/ruby -r ./siteconf20181008-8195-mkl9qp.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... no
-----
mysql client is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.
-----
*** 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
    --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/tomohiro/.rvm/rubies/ruby-2.5.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

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

  /Users/tomohiro/.rvm/gems/ruby-2.5.1/extensions/x86_64-darwin-17/2.5.0/mysql2-0.5.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/tomohiro/.rvm/gems/ruby-2.5.1/gems/mysql2-0.5.2 for inspection.
Results logged to /Users/tomohiro/.rvm/gems/ruby-2.5.1/extensions/x86_64-darwin-17/2.5.0/mysql2-0.5.2/gem_make.out

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mysql2
***:myapp tomohiro$ vim Gemfile
***:myapp tomohiro$ gem install mysql2 -v '0.5.2'
Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /Users/tomohiro/.rvm/gems/ruby-2.5.1/gems/mysql2-0.5.2/ext/mysql2
/Users/tomohiro/.rvm/rubies/ruby-2.5.1/bin/ruby -r ./siteconf20181008-23066-kdlewc.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... no
-----
mysql client is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.
-----
*** 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
    --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/tomohiro/.rvm/rubies/ruby-2.5.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

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

  /Users/tomohiro/.rvm/gems/ruby-2.5.1/extensions/x86_64-darwin-17/2.5.0/mysql2-0.5.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/tomohiro/.rvm/gems/ruby-2.5.1/gems/mysql2-0.5.2 for inspection.
Results logged to /Users/tomohiro/.rvm/gems/ruby-2.5.1/extensions/x86_64-darwin-17/2.5.0/mysql2-0.5.2/gem_make.out