ruby 1.8.7
Rails 2.2.2
mysql gem 2.7
Linux 2.6.18-92.el5
Hey guys. The MySQL gem is puzzling me. When I run irb> require
‘mysql’ I get the error shown below:
- irb(main):001:0> require ‘rubygems’
- => true
- irb(main):002:0> require ‘mysql’
- LoadError: libmysqlclient.so.16: cannot open shared object file:
No such file or directory - /usr/local/lib/ruby/gems/1.8/gems/
mysql-2.7/lib/mysql.so -
from /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/
mysql.so
6. from /usr/local/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:36:in `require’
7. from (irb):2
It says “no such file or directory” when in fact that file, mysql.so,
absolutely does exist in that exact location.
After some Googling I found that I could use ldconfig to configure
mysql.so to be available to the whole system. Once I added “/usr/local/
mysql/lib” to /etc/ld.so.conf and ran ldconfig, it worked fine:
- irb(main):002:0> require ‘rubygems’
- => true
- irb(main):003:0> require ‘mysql’
- => true
OK, so I got it to work. But my question is, why was I getting that
error previously? I never had to use ldconfig before to get the mysql
gem to work. Has anyone else encountered the same error? Is there a
better solution?
This is how I installed the mysql gem:
- gem install mysql --no-rdoc --no-ri \
- – --with-mysql-include=/usr/local/mysql/include \
- –with-mysql-lib=/usr/local/mysql/lib \
- –with-mysql-config=/usr/local/mysql/bin/mysql_config
Any insight would be greatly appreciated.
Thanks,
E