Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql.h is missing .... (Ruby on Rails, OSX)

I tried several ideas ... none of them worked ... I'm just trying to install mysql2 as a gem. My mysql is working, but every time my system says, that mysql.h is missing ... Has someone an idea? It's very frustrating now ...

I'm using osx 10.8.3, ruby 1.9.3, rails 3.2.13 and home-brew.

    gem install mysql2 -v '0.3.11'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

        /Users/gadreel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
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
    --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/gadreel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
    --with-mysql-config
    --without-mysql-config

    file `which mysql`
    /usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64
like image 736
gadreel Avatar asked May 20 '13 19:05

gadreel


1 Answers

What worked for me in Mountain Lion Rails install(using Homebrew and RVM) was editing /usr/local/Cellar/mysql/5.XX.XX/bin/mysql_config and removing -Wno-null-conversion -Wno-unused-private-field from cxflags and cxflags options as follows:

Before:

cflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!

After:

cflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!

After that gem install mysql2 proceeded without hickups

Note: this is probably due to a change introduced to mysql_config after 5.6.10: http://bugs.mysql.com/bug.php?id=69645

like image 66
Vlad Gurovich Avatar answered Sep 18 '22 21:09

Vlad Gurovich