Search code examples
ruby-on-railsmacosmysql2

Rails server won't start after brew update


On my mac (sonoma), I installed wget: "brew install wget", which worked fine, but noticed it updated mysql as well. It went from 8.0.x to 8.3.0.

I then could no longer start my rails server locally. The error on startup:

 dlopen(/Users/jack/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib (LoadError)
  Referenced from: <E4E7E7D5-64FA-3F2B-8B01-B6F82F206D57> /Users/jack/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle
  Reason: tried: '/opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib' (no such file), 

I noticed that there is a libmysqlclient.23.dylib file in there, not the 22. I did try reinstalling the gem to no avail. How to fix?

Thx.


Solution

  • Ok, I finally found this article, which solved my problem. Note that the issue was the inability to install the mysql2 gem properly. I had tried different ways to install it from different articles, to no avail. This is the one that worked.

    https://prabinpoudel.com.np/notes/error-while-installing-mysql2-in-m1-mac/

    Careful with cut-n-pasting the cmd from the article (the big long one to install the gem). I recommend just creating a shell script and typing it in to do the install since it's easy to have typos.