Installing the MySQL Gem on Red Hat Enterprise Linux

This entry was posted August 7 2009 under Uncategorized.

No comments

There is nothing quite so much fun as installing the MySQL gem for Ruby. It seems like every time I try to do it I wind up with a different issue. Today’s issue was simple yet easy. When running gem install mysql I was greeted by this lovely message:


ERROR:  Error installing mysql:
	ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb --with-mysql-conf=/usr/bin/mysql --with-mysql-lib=/usr/lib/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
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.

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=/usr/local/bin/ruby
	--with-mysql-config
	--without-mysql-config
	--with-mysql-dir
	--without-mysql-dir
	--with-mysql-include
	--without-mysql-include=${mysql-dir}/include
	--with-mysql-lib=${mysql-dir}/lib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-mlib
	--without-mlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-zlib
	--without-zlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-socketlib
	--without-socketlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-nsllib
	--without-nsllib
	--with-mysqlclientlib
	--without-mysqlclientlib

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Thankfully this can be fixed fairly easily with two steps:

yum install mysql-devel
gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

Success!

Post a Comment







OMG Who?

I'm Sean Roberts, a 24-year-old Ruby on Rails developer currently working for Hamilton web design firm factor[e] design initiative. This is my blog about work and nerd stuff, and maybe a little bit about music and food too.

I'm On Twitter!

  • The motto for RubyGems should be "can't someone else do it?" 2010-10-25
  • New Superchunk makes me feel like I'm 17, anyone up for semi-ironically playing Mario Kart 64 and making Kraft Dinner? 2010-09-24
  • what an unfortunate (yet hilarious) name http://imgur.com/2biWk 2010-09-22
  • Hey Google, stop interrupting me when I'm trying to ask you a question! 2010-09-09
  • My new book will be called "Living in Synergy: Memoirs of an Unwed Power Couple" (with help from @EKinread of course) 2010-09-01
  • Can anyone recommend a good tailor in Hamilton? 2010-08-23
  • More updates...