Rails 3.0, Mysql2, Ruby 2.1.0 and undefined symbol: __gxx_personality_v0 – mysql2.so

If you encounter this type of error with your not-migrated/really old Rails 3.0 apps:

/app/.bundle/ruby/2.1.0/extensions/x86-linux/2.1.0/mysql2-0.2.18/mysql2/mysql2.so: 
undefined symbol: __gxx_personality_v0 - /app/.bundle/ruby/2.1.0/extensions/x86-linux/2.1.0/mysql2-0.2.18/mysql2/mysql2.so (LoadError)
  /app/.bundle/ruby/2.1.0/gems/mysql2-0.2.18/lib/mysql2.rb:9:in `require'
  /app/.bundle/ruby/2.1.0/gems/mysql2-0.2.18/lib/mysql2.rb:9:in `<top (required)>'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
  /app/config/application.rb:3:in `<top (required)>'
  /app/config/environment.rb:2:in `require'
  /app/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'

You need to change your mysql2 gem version. You can't use mysql2 gem version 0.3.*. Instead you need to use branch 0.2.*:

gem 'rails', '~> 3.0'
gem 'mysql2', "~> 0.2.21"

After that just bundle install and the error should be gone.

Categories: Rails, Ruby, Software

2 Comments

  1. Why can we not use mysql2 gen version 0.3*?

  2. Maciej Mensfeld

    May 8, 2015 — 15:48

    Because you will get this error although there might be 0.3.* version that will work. I’ve updated this app to new rails version, so I don’t have this issue anymore.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑