views:

335

answers:

2

Hi.

I have Jruby gem Mysql installed on my machine. However due to some reason, I had to move to ruby instead of ruby and everything seems to be working fine except that mysql gem for ruby isn't installed and now when I try to install Mysql gem i get following error:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb --with-mysql-dir=/usr/include/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... no
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
checking for main() in -lmygcc... no
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

I googled and found that I might need to install libmysqlclient12-dev

But when I tried doing that, I got following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libmysqlclient12-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package libmysqlclient12-dev has no installation candidate

Now I seem to be hitting the wall and not move ahead with this. Any pointers or help will be appreciated.

Cheers

+1  A: 

Which gem command are you using? The ruby one or the jruby one?

Try which gem if you're on *unix.

Have a look at your path to make sure the C-ruby binaries are in front of the JRuby binaries (or remove JRuby from your path if you're not going to use it anymore).

Rob
+1  A: 

I'm guessing from the package manager that you're running Linux.

libmysqlclient12-dev is an Ubuntu package. If you're running some other distro it's very probably just named something else. I believe that the Fedora package you'd need is mysql-devel. If you do some searching around with the name of your distro and libmysqlclient12-dev you can probably find exactly what it is.

Your distribution may also have pre-built versions of some of the gems. Fedora (which is what I use) doesn't have a mysql gem pre-built, but another distrubution might. In Fedora they're named rubygem-GEMNAME depending on the gem. For example, the sqlite pre-built gem is rubygem-sqlite3-ruby.

Sam DeFabbia-Kane