Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql2: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib after homebrew update

After I upgraded mac OS Mojave from v10.14.0 to v10.14.2 and all the packages installed with Homebrew I started getting the following error when I run bin/rails console:

/Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.4/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /usr/local/opt/[email protected]/lib/libmysqlclient.18.dylib
  Reason: image not found - /Users/hirurg103/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.4/lib/mysql2/mysql2.bundle

I tried to uninstall mysql2 gem and install it with cpp and ld flags:

gem uninstall mysql2
gem install mysql2 -v 0.4.4 -- --with-cppflags=-I/usr/local/opt/openssl/include/openssl --with-ldflags=-L/usr/local/opt/openssl/lib

But it didn't help.

Also I tried to upgrade mysql2 to the latest version (v0.5.3 at the time of writing this post), but it didn't work either

ls -l /usr/local/opt/openssl/lib gives me:

total 14472
drwxr-xr-x  4 hirurg103  staff      128 Sep 10 16:13 engines-1.1
-r--r--r--  1 hirurg103  staff  2265596 Dec 13 19:06 libcrypto.1.1.dylib
-r--r--r--  1 hirurg103  staff  3930864 Sep 10 16:13 libcrypto.a
lrwxr-xr-x  1 hirurg103  staff       19 Sep 10 16:13 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--  1 hirurg103  staff   485860 Dec 13 19:06 libssl.1.1.dylib
-r--r--r--  1 hirurg103  staff   720400 Sep 10 16:13 libssl.a
lrwxr-xr-x  1 hirurg103  staff       16 Sep 10 16:13 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x  5 hirurg103  staff      160 Dec 13 19:06 pkgconfig

I do not see libssl.1.0.0.dylib there mysql2 complains about

Have you met this error before? Were you able to fix it and how?

like image 424
Hirurg103 Avatar asked Dec 13 '19 17:12

Hirurg103


2 Answers

OpenSSL 1.0 reached EOL on 2019-12-31

Reinstalling mysql2 gem with --with-cflags and --with-ldflags arguments pointing to [email protected] fixed the error:

gem uninstall mysql2
gem install mysql2 -v 0.4.4 -- --with-cflags=\"-I/usr/local/opt/[email protected]/include\" --with-ldflags=\"-L/usr/local/opt/[email protected]/lib\"

bundle install
like image 96
Hirurg103 Avatar answered Oct 21 '22 16:10

Hirurg103


The solution for me ultimately was:

brew update
brew upgrade

Prior to trying these commands, I also had tried brew reinstall openssl several times. I also exported LIBRARY_PATH: export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ AND I reinstalled ruby via rbenv.

So, if the brew update and upgrade doesn't clear the error for you, perhaps try reinstalling openssl. Then if that doesn't work, reinstall ruby.

like image 29
Capella Avatar answered Oct 21 '22 14:10

Capella