On some of our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer be installed on Ubuntu 20.04. Trying this either leads to errors when compiling the native extension, or a segfaults when using it.
For Rails 4.2, mysql2 version 0.4.10 seems to work okay. If you still have issues, upgrade to 0.5.x, which should be compatible.
To install it, you have to switch the mysql2 gem to our fork Show archive.org snapshot . In your Gemfile, change mysql2 to either
# for Rails 2.3
gem 'mysql2', :git =>'https://github.com/makandra/mysql2', :branch => '0.2.x-lts'
# for Rails 3.x
gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts'
If you run into issues when compiling, make sure you have libmariadb-dev
installed:
sudo apt remove libmysqlclient-dev
sudo apt install libmariadb-dev
If you have installed mysql2
gems before switching to the fork and installed libmariadb-dev, you might need to uninstall and reinstall all mysql2
versions in all your Rubies.