MySQL2 gem became a frequent problem for people who use macOS to develop Ruby1 based apps that utilized MySQL2 data store. I’ve personally encountered this problem myself back in the days and still encounter this on brand new setup macOS workstation. In this article, we will go through the steps I took to resolve this problem.
Tradition lives because young people come along who catch its romance and add new glories to it.
— Michael Novak.
We assume here you have some basic knowledge on setting up Ruby and command line tools on macOS.
- Ruby (Latest)
- Bundler3 (Latest)
- Homebrew4 (Installed and no problems, run and check
brew doctorfor more info and if the installation is okay)
What did I do to solve the problem?
Here’s what I’ve done to resolve the problem.
- First is to install
gnutls(choose your poison). Both are great and have some pros and cons, but most people would use
openssland that’s what I preferred.
brew install openssl
- Then we point
mysql2dependency to the installed
opensslpackage from Homebrew.
bundle config --global build.mysql2 --with-opt="$(brew --prefix openssl)"
- Of that, we install the
mysql2dependency and all the sub-dependents that are needed.
That’s all needed to install
mysql2 on a fresh macOS Mojave. Now you can develop a ruby app that utilizes MySQL as a data store.
So, guys, let me know if you encounter any problems? or any additional ways to install
mysql2. That’s it guys hope you enjoyed this article and as always live life.
- Ruby is an interpreted, high-level, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan. Ruby is dynamically typed and uses garbage collection. ↩︎
- MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language. ↩︎
- Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. ↩︎
- Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. The name is intended to suggest the idea of building software on the Mac depending on the user’s taste. ↩︎