tutorial
gem install mysql2
·
1 min read
I’ve come across this error several times throughout my development career so I figured it was finally time to write it down.
Scenario #
Whenever I try to install certain versions of the mysql2
gem in a Ruby on Rails application, I get the following error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension...make "DESTDIR="compiling client.ccompiling infile.ccompiling mysql2_ext.ccompiling result.ccompiling statement.clinking shared-object mysql2/mysql2.bundleld: library not found for -lsslclang: error: linker command failed with exit code 1 (use -v to see invocation)make: *** [mysql2.bundle] Error 1 make failed, exit code 2 An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.Make sure that `gem install mysql2 -v '0.5.2'` succeeds before bundling.
Solution #
In order to fix this issue on macOS, first make sure that you have cmake
installed.
brew install cmake
Then you can install the gem via the following command:
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Hope this helps save someone some time!