Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl

Install mysql2 gem.

gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
@repoles

This comment has been minimized.

Copy link

repoles commented Oct 4, 2018

Thanks, man!

@swaincreates

This comment has been minimized.

Copy link

swaincreates commented Oct 5, 2018

Heroic

@vincepreziose

This comment has been minimized.

Copy link

vincepreziose commented Oct 13, 2018

Yaasss!

@mgoggin

This comment has been minimized.

Copy link

mgoggin commented Oct 18, 2018

If you came here because you're trying to bundle your project into a specific directory and the gem won't build, you can tell bundler to use these build flags when it installs the gem.

bundle config build.mysql2 --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
bundle install --path .bundle
@mckomo

This comment has been minimized.

Copy link

mckomo commented Nov 28, 2018

Thanks!

@nagative

This comment has been minimized.

Copy link

nagative commented Dec 16, 2018

Thank you so much! You were a big help!

@s1monw1

This comment has been minimized.

Copy link

s1monw1 commented Dec 28, 2018

took me an hour until I finally found your solution, thanks!

@rslhdyt

This comment has been minimized.

Copy link

rslhdyt commented Jan 18, 2019

save my life

@rikas

This comment has been minimized.

Copy link

rikas commented Jan 20, 2019

I still get this error:

cannot load such file -- mysql2/mysql2

when trying to use mysql2 on Rails (5.2.2)

@Stratus3D

This comment has been minimized.

Copy link

Stratus3D commented Jan 23, 2019

Works on my machine!

@tr00gle

This comment has been minimized.

Copy link

tr00gle commented Jan 24, 2019

Just found this, and it was immensely helpful. How did you reach this solution?

@giuseb

This comment has been minimized.

Copy link

giuseb commented Jan 29, 2019

excellent, thanks!

@bearpatrol64

This comment has been minimized.

Copy link

bearpatrol64 commented Jan 31, 2019

Hurray!!! That did it!
Thank you!

@rbercam

This comment has been minimized.

Copy link

rbercam commented Feb 5, 2019

Thank you!

@katherine-boost

This comment has been minimized.

Copy link

katherine-boost commented Feb 11, 2019

Much appreciated!

@FlavioLudi

This comment has been minimized.

Copy link

FlavioLudi commented Feb 12, 2019

Thanks!

@kabaken

This comment has been minimized.

Copy link

kabaken commented Feb 13, 2019

ありがとう!

@samholst

This comment has been minimized.

Copy link

samholst commented Feb 20, 2019

You the man!

@CiTroNaK

This comment has been minimized.

Copy link

CiTroNaK commented Feb 21, 2019

Thanks!

@bthibault

This comment has been minimized.

Copy link

bthibault commented Feb 22, 2019

🥇

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