Roy Zinn
Roy Zinn

Reputation: 37

fail to install mysql2 gem

I'm trying to setup a not so old (but still few years) of Rails project on new Mavericks machine. When I try to bundle, i keep getting this error (sorry for the long code):

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/royzinn/.rbenv/versions/1.8.7-p352/bin/ruby extconf.rb --with-mysql-config=/usr/local/Cellar/mysql/5.5.20/bin/mysql_config
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of 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
    --without-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/royzinn/.rbenv/versions/1.8.7-p352/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18 for     inspection.
Results logged to /Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18/ext/mysql2/gem_make.out

Before that I had a message saying that the gem was built for MySQL version 5.5.20 and that I have already activated other (more advanced) MySQL.

I "cleaned" everything with Homebrew, tried to reinstall but nothing seems to work.

Any help is highly appreciated. Thanks!

Upvotes: 0

Views: 310

Answers (2)

scarver2
scarver2

Reputation: 7995

First, make sure the gem can compile on installation.

gem install mysql

If you get an error that the gem won't compile, it may be necessary to install MySQL where Bundler can find it--even though it is included with OS X. Rather than passing paths as arguments to Bundler, just install MySQL with Homebrew and then install the gem.

brew install mysql
gem install mysql2

Finally, the mysql2 gem's version is probably out of date in the Gemfile and needs to be updated.

bundle update mysql2

Upvotes: 0

Alex Stanovsky
Alex Stanovsky

Reputation: 1376

Try to delete this directory :

/Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18  

If this doesn't help delete rvm directory and reinstall

Upvotes: 1

Related Questions