Installing the mysql gem on (x86_64) Fedora has always been a more tedious piece of work, because of the way the Fedora team handles ruby and the mysql development files and mainly of course because we still have to use (and compile) native code here.
Having documented this before, I wrongly felt prepared when I tried this today. But this time it is rvm and ruby 1.9.2 in my first attempt to build a rails 3 app. I have liked the idea of application templates from when they were introduced, so I was following the Readme in Les Hill’s Rails 3 App Generator. Which includes the
bundle install
command. As things are a little different on Fedora, this fails (the mysql_config script, even if it is installed cannot be found). Always has for me, at least. So I go and install some dependencies first (some of this is standard fare on my Fedora machines):
$ sudo yum -y groupinstall "Development Tools"
$ sudo yum -y install ruby-devel mysql-devel
What happened then, upon doing the usual
gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
gave me some extra problem this time with a message including this:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/home/sroegner/.rvm/rubies/ruby-1.9.2-preview3/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config --with-opt-include=/usr/include/mysql
checking for mysql_ssl_set()... *** 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.
Long story short: the missing piece was the openssl-devel rpm:
$ sudo yum -y install openssl-devel
$ gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...