2
votes

Just updated to macOS Mojave, reinstalled mysql via brew & downloaded latest xcode 9.2 . While triying to setup a development enviroment for an old rails project, bundle crashes on installation of mysql2 gem. In the beggining i thought it was because latest mysql2 version, is not compatible with ruby 1.9 so i tried:

gem install mysql2 -v '0.3.17'

and i received:

/Users/me/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb checking for ruby/thread.h... * 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/me/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:intry_cpp' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in block in have_header' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in have_header' from extconf.rb:9:in'

copy from /Users/me/.rvm/gems/ruby-1.9.3-p125@mailcatcher/gems/mysql2-0.2.18/ext/mysql2/mkmf.log:

"/usr/bin/gcc-4.2 -o conftest -I/Users/me/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/me/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/backward -I/Users/me/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. -I/Users/me/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/me/.rvm/rubies/ruby-1.9.3-p125/lib -L/Users/me/.rvm/usr/lib -L. -L/usr/local/lib -lruby.1.9.1 -lpthread -ldl -lobjc " checked program was: /* begin / 1: #include "ruby.h" 2: 3: int main() {return 0;} / end */

2
Did you open XCode after installation and accept its license agreement? Did you install the Command Line Developer Tools?spickermann
@spickermann You mean x-code? If so, yes already did that.HaCos

2 Answers

3
votes

It sounds like you're either missing the XCode command line tools: xcode-select --install

Or mySQL packages: If you don't already have homebrew: $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Then to install mysql: brew install mysql

I can't remember which solved this issue for me in the past but I'm sure it was one of them.

0
votes

Cross linking my answer to almost this exact same question. I think it might just be not finding the correct config path

sudo gem install mysql2 -- --with-mysql-config=/usr/local/bin/mysql_config

See the answer here

edit: formatting