0

Since upgrading to Ubuntu LTS 20.04 (from LTS 18), I've been bumped to the newer version of MySQL (from v5.7.3 to 8.0.16). All databases and configurations have been updated successfully, but the MySQL2 gem insists on trying to build against an older version of libmysqlclient (libmysqlclient.so.20 rather than the newer libmysqlclient.so.21)

I've uninstalled and reinstalled the APT packages: mysql-server and libmysqlclient-dev, as well as uninstalling and reinstalling the MySQL2 gem, but with no effect.

As you can see from the data below, it still appears to be incorrectly linking and I can't find a way to make it link to the correct version. Any help much appreciated.

$ gem list mysql2

*** LOCAL GEMS ***

mysql2 (0.5.3)

$ mysql -v -u *** -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.21-0ubuntu0.20.04.4 (Ubuntu)

$ RAILS_ENV=production bundle exec rails c
Traceback (most recent call last):
     1: from /home/**/**/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<top (required)>'
/home/rails/kwai/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `require': libmysqlclient.so.20: cannot open shared object file: No such file or directory - /home/rails/kwai/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so (LoadError)

$ ldd mysql2.so
    linux-vdso.so.1 (0x00007fffa3b5e000)
    libruby.so.2.6 => /home/***/.rvm/rubies/ruby-2.6.3/lib/libruby.so.2.6 (0x00007f8d4c92d000)
    libmysqlclient.so.20 => not found
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8d4c902000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8d4c710000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8d4c6f4000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8d4c6e9000)
    libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f8d4c663000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8d4c65d000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f8d4c622000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8d4c4d3000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8d4cecc000)

$ ls -l /usr/lib/x86_64-linux-gnu/libmy*
-rw-r--r-- 1 root root 9242056 Aug  4 12:39 /usr/lib/x86_64-linux-gnu/libmysqlclient.a
lrwxrwxrwx 1 root root      20 Aug  4 12:39 /usr/lib/x86_64-linux-gnu/libmysqlclient.so -> libmysqlclient.so.21
lrwxrwxrwx 1 root root      25 Aug  4 12:39 /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21 -> libmysqlclient.so.21.1.21
-rw-r--r-- 1 root root 7264264 Aug  4 12:39 /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.1.21

2 Answers 2

1

I deleted

./vendor/bundle/ruby/2.7.0/specifications/mysql2-0.5.3.gemspec
./vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3
./vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2

And it works. Thank you

1
  • Glad to hear it! Took me far to long to work out but I'm happy to hear that it has helped someone else.
    – Kitebuggy
    Oct 7, 2020 at 8:06
0

Finally solved it. I had to manually delete all previous copies of the gems in all builder and .rvm folders and then the gem seem to compile properly and everything worked again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.