开发者

Install MySQL gem for Ruby along with JRuby gem

I have the JRuby MySQL gem installed on my machine. However, for some reason I had to change to Ruby instead of JRuby and everything seems to be working fine except that the MySQL gem for Ruby isn't installed and now when I try to install it 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开发者_如何学Python 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 the libmysqlclient12-dev package.

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


I had the same issue. I did

apt-get install libmysqlclient-dev

on Ubuntu, and it worked.


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜