简体   繁体   中英

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?

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

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.

A few things:

Ruby 1.9.1 has many known errors with rails (3+), consider upgrading to 1.9.2.

Did you manually install the mysql2 gem, then add it to your Gemfile? If so, manually uninstall it (All versions) - then run bundle install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM