After setting database to mysql, bundle install causes an error

※memorandum

problem

After changing the database to mysql, I got an error when creating an app with Rails.

Execution command

$ rails _5.2.4_ new app_name --skip-coffee --database=mysql
gem 'pry-rails'
$ bundle install

error contents

(abridgement)
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/fengjianlengfu/.rbenv/gems/2.6.0/gems/mysql2-0.5.3 for
inspection.
Results logged to
/Users/fengjianlengfu/.rbenv/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.3/gem_make.out

What i did

-Execute the command of the log contents (could not be resolved)

gem install mysql2 -v '0.5.2'

・ Find a solution for someone who is giving a similar error

This person was written, and it was installed without error.

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

What i found

・ It seems that this part was the cause.

ld: library not found for -lssl

-The above error occurs when the library called ssl cannot be loaded. → The library does not exist or the connection link to the library is incorrect.

-$ Bundle config --local is set for the local application. → [Reference 1](https://qiita.com/SAYJOY/items/dd7c8fc7a3647e7ff969#%E8%A7%A3%E6%B1%BA%E7%AD%96%E3%81%AB%E3%81%A4 % E3% 81% 84% E3% 81% A6) Reference 2

Impressions

To be honest, I don't understand why it was solved this way. I would like to look back as I study in the future.

Recommended Posts

After setting database to mysql, bundle install causes an error
Error with bundle install after upgrading to Catalina
mysql2 fails to install with bundle install
What to do if mysql2 gets a bundle install error
bundle install error
bundle install error
Add gem'rails-i18n','~> 6.0.0' and what to do if bundle install gives an error
What to do if an error occurs when nokogiri enters when bundle install
When deploying to Heroku, OpenApp causes an error
Error when bundle install
How to install MySQL
bundle install does not install mysql2
Response to WSL2 docker throwing an error after updating Docker for Windows
[Java] Adding an element to the Collection causes a compile error
Laravel, composer install causes an error in PackageManifest, so resolve it
I don't see an error in Rails bundle install ... the solution
Processing to issue an error message
Rails new fails to install mysql
Steps to install MySQL 8 on CentOS 8
What to do after Vagrant install
[Rails / MySQL] Database logical name setting
[Rails 6] MySQL 2 cannot be bundle install
Error summary in bundle install. memorandum
If the bundle install command on the Docker container ends with an error at code: 15, check the BUNDLE_PATH setting
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
I get an error with bundle install and puma cannot be installed.
What to do and how to install when an error occurs in DXRuby 1.4.7
I want to display an error message when registering in the database
Copying the repository and getting a mysql2 error on the first bundle install
Solution that gives an error when trying to connect to DB (MySQL) in Java