Brad Rice
Brad Rice

Reputation: 1344

Difficulty in installing mysql gem on OSX

If it makes any difference, I did just update to Mountain Lion, I don't know if that complicates this process.

I'm trying to get started with a Sinatra app that will connect to a MySql database. I've got a Gemfile set up and am running a bundle install and get the following output:

Fetching gem metadata from http://rubygems.org/.....
Using haml (3.1.6) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/brad/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... *** 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/brad/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
 /Users/brad/.rvm/rubies/ruby-1.9.3-p194/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/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
         from extconf.rb:9:in `<main>'


 Gem files will remain installed in /Users/brad/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
 Results logged to /Users/brad/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
 An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
 Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

So everywhere online says to download mysql right? I got homebrew and ran brew install mysql To the best of my knowledge, it was successful. I have paths and folders and stuff, but I DON'T have the mysql_config file. Anywhere. Did the install fail? What do I need to do to get that file? Again, I'm on Mac, so I can't apt-get install any dev file, that seemed to help a lot of people. I'm very confused. Any help would be awesome.

Upvotes: 1

Views: 731

Answers (2)

filipebarcos
filipebarcos

Reputation: 69

You can just xcode-select --install to install command line tools, after that, everything should work fine

Upvotes: 0

Brad Rice
Brad Rice

Reputation: 1344

Recompiling Ruby fixed the issue. Props to iltempo. Idk how to upvote a comment...

Upvotes: 1

Related Questions