25th Jun, 2009

No such file to load mysql - Ruby on Rails [even after gem install mysql]

You may face some issues while configuring rails;

no such file to load — mysql
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:65:in `mysql_connection’
and so on

step 1:
If you havn’t done “gem install mysql”; do it first.

step 2:
If it doesn’t work even after “gem install mysql”; search for “mysql.so” in your system. In linux box; the path would be something like;
‘/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.so’

step 3:
In the error message; you will see the error file(mysql_adapter.rb); In my case it is [check error sample above];

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:65:in `mysql_connection’

step 4:
Open the file “/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb” and go to location 65.

You will find a line something like;

require_library_or_gem(’mysql’)

change this line to look like;

require_library_or_gem(’/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.so’)

Restart your app and ;)

Leave a response

Your response:

Categories and Tags

Advertising