[Ruby] mysql2 not installed with bundle install

less than 1 minute read

Introduction

I get an error every time in my local environment so make a note of the solution *I don’t know the exact cause yet, but this is the content that I passed for the time being

$ bundle install --path vendor/bundle
...
Error statement ↓
An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.

Solution

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
$ bundle install --path vendor/bundle

Executing the above command will add the following line to .bundle/config

BUNDLE_BUILD__MYSQL2: "--with-ldflags=-L/usr/local/opt/openssl/lib"

Come to the end.