Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3. no such file to load -- mysql2/mysql2 in Production

I get this error no such file to load -- mysql2/mysql2 from Passenger in production.

Details about this error /var/www/releases/20120103021152/vendor/cache/ruby/1.9.1/gems/mysql2-0.2.18/lib/mysql2.rb and it is true, that file doesn't not exist.

Why am I getting this error? How can I fix it?

like image 725
leonel Avatar asked Dec 22 '22 04:12

leonel


2 Answers

I've got same error.

rails s
 {railsroot}/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require':
 cannot load such file -- mysql2/mysql2 (LoadError)  

The following has worked.
('{railsroot}/vendor/bundle/ruby/1.9.1/gems/' will depends on your system.)

cd {railsroot}/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/mysql2/ext
ruby extconf.rb
make
make install

cd {railsroot}/vendor/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri
ruby extconf.rb
make
make install
like image 71
akazah Avatar answered Jan 08 '23 02:01

akazah


I ended up manually deleting all the gems inside my gems folder and running bundle install. The troublesome gem (a mysql-2.0.18 or something gem version) stopped being installed.

like image 23
leonel Avatar answered Jan 08 '23 01:01

leonel