[Ruby] Library not loaded when I try to rails s by upgrading ruby version

less than 1 minute read

Error excerpt

/Users/hoge-user/projects/freee-auth/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/hoge-user/projects/freee-auth/vendor/bundle/ruby/2.6.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr /local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /Users/hoge-user/projects/freee-auth/vendor/bundle/ruby/2.6.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
  Reason: image not found-/Users/hoge-user/projects/freee-auth/vendor/bundle/ruby/2.6.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle

Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError) Bundle doctor

The following gems are missing OS dependencies:
 * mysql2: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
 * mysql2: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

I’m saying I’m missing something in the openssl family that mysql depends on. Is it because I replaced openssl with the version upgrade of ruby? So I installed mysql again and replaced the dependent gem library.

bundle exec gem uninstall mysql2
bundle install # mysql gem should also come in

rails s worked fine

$ bundle exec rails s -p 3099
=> Booting Puma
=> Rails application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 4.3.1 (ruby 2.6.6-p146), codename: Mysterious Traveler
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://
* Listening on tcp://[::1]:3099