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!

  • Can anyone recommend a good tailor in Hamilton? 1 week ago
  • Alphabits are a highly underrated cereal. Just saying. 1 week ago
  • Oh look, another good deal on a product that I need and can't find at a store around here. Do they ship to Canada? Of course not. 2 weeks ago
  • RT @JayHiggins: I'm going to be positive: Games big success, Ticats sold to billionare, LRT, Condo Dev at WH, Bettman retires 3 weeks ago
  • Wait, Hamilton has a football team? 3 weeks ago
  • Hooray for west harbour! I promise to not be sarcastic RE: government for a couple days. Probably. 3 weeks ago
  • More updates...