Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zulhfreelancer/5b7200ec26ea43a467e3ac3889ec2561 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/5b7200ec26ea43a467e3ac3889ec2561 to your computer and use it in GitHub Desktop.
How to install mysql2 0.5.3 gem on Ruby 2.7.8 + Homebrew MySQL 8.0 environment

How to install mysql2 0.5.3 gem on Ruby 2.7.8 + Homebrew MySQL 8.0 environment

# this is installed via asdf
$ ruby -v
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-darwin24]

$ brew list --versions | grep mysql
mysql-client 9.0.1
[email protected] 8.0.39
[email protected] 8.0.39_5

$ brew info [email protected] | grep FLAGS
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

# replace --with-ldflags and --with-cppflags with values returned from previous command
$ gem install mysql2 -v '0.5.3' -- --with-ldflags='-L/usr/local/opt/[email protected]/lib' --with-cppflags='-I/usr/local/opt/[email protected]/include' --with-cflags="-Wno-incompatible-pointer-types -Wdeprecated-non-prototype -Wincompatible-function-pointer-types"

$ bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment