Whilst reading guides on how to setup a rails dev server under OS X (both Tiger and Leopard), I kept running into issues installing the mysql gem. The guides would instruct you to install the mysql client libraries from the mysql website, which is fine. But to get improved performance under rails, you must install the mysql gem, but in doing so, I would constantly run into issues getting the gem to install correctly. The issues normally arises after running the following command:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
And the resulting error is:
checking for mysql_query() in -lmysqlclient... no *** 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.
Basically, the gem compile fails as a result of not knowing where the correct mysql files are, despite the fact that the command line switch points to the mysql folder.
To fix this problem, use a line like the following:
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Note that instead of pointing at the mysql folder, we are pointing at a mysql config which is bundled with the mysql client install files.
Had the same problem, and fixed it per your post. Thanks!
I also had the same issue and your instructions fixed them. Thanks a ton
thanks !
Another big thanks! Just what I needed.
Helped here too. Many thanks.
THX you guy! It helps!!
THX! Worked for me too!
thanks
Same problem, same solution. Thanks for the help!
Great, thanks, worked for me too.
Dude you rock. Thanks
Wow, thanks. That really helped!
worked like a gem. thanks!
this is AWESOME. thanks.
I love you, and would like to have your babies. This has been flummoxing me for ages.
Thanks a lot.
Sweet! I can’t understand how will people know these tricks.. and when will be able to give such advice..
You rock. Thank you!!!
Awesome! It took three hours to figure this thing out.
Thank you!
Thanks!
Gracias!
I guess that a bug report needs to be submitted somewhere.
Good stuff, thanks!
If using jruby, above commond will still through an error. You will need to architecture flag. Here is the command for jruby
sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
# This sets the ARCHFLAGS environment variable to your native architecture
THANK YOU!!!!
Much thanks!
U DA MAN
I’ve got wsod when I’m adding comment here;/
I’ve got similar problem, but this solution wasn’t helpful for me.
In my case I haven’t gcc installed;/
Read more: http://easyanswers.org/question/extconfrb-failed-gem-install-mysql
Worked, Thanks!
Brilliant! thanks
I spend lots of time searching to make it work.
you have the solution,it finally work.
thanks very much
Just a quick note, I was using MacPorts to install and was running into the same errors. The fix was to point the installer to where MacPorts installed mysql_config… like this:
sudo gem install mysql — –with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Thanks! I’ve spent a lot of time searching for a solution, and this did it for me!
Worked a treat! Thanks a lot! :)
Woohoo! Thank you.
Like the others before. Thank you soooo much. Saved my ass. =)
Got it working for me as well. Many thanks
exactly! thank you 1000*times :-)
it didnt help me
i am using snow leopard
my error is of following type
$ sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/opt/local/bin/ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()… no
checking for rb_str_set_len()… no
checking for rb_thread_start_timer()… no
checking for mysql.h… no
checking for mysql/mysql.h… no
*** 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=/opt/local/bin/ruby
–with-mysql-config
Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
please help me out of here..
thanks
A big THANK YOU!
@gagan shrestha: I’m not familiar with the setup of Rails & Ruby on Snow Leopard – Sorry!
Worked like a charm, thanks ..