1
0

More than 1 year has passed since last update.

Bundle installでmysql2がインストールできない

Posted at

Bundle installでmysql2がインストールできない

$ bundle install

(省略)

An error occurred while installing mysql2(0.5.3), and Bundle cannot continue.
Make sure that `gem intall mysql2 -v '0.5.3' --source 'https://rubygems.org/'`

In Gemfile:
mysql2

ログに吐かれたエラー文を確認

directory not found for option '-L/usr/local/opt/openssl/lib'

lsでディレクトリの確認

$ ls /usr/local/opt/openssl/lib

ディレクトリが存在しないことがわかった。

brew install openssl で opensslのパスを確認

==> openssl@3:stable 3.0.7(bottled)[keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@3.rb
License: Apache-2.0
==> Dependencies
Required: ca-certifiates
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add addtional certificates, place .pem file in
/usr/local/etc/openssl@3/certs

and run
/usr/local/opt/openssl@3/bin/c_rehash
because macOS provides LibreSSL.

==> Analytics
install: 177,863 (30 days), 445,966 (90 days), 1,640,846 (365 days)
install-on-request: 94,320 (30 days), 286,031 (90 days), 1,225,062 (365 days)
build-error: 970 (30 days)

openSSLの3.0.7が存在しているのは認知しているが、インストールされていないとのこと

バージョン確認

$ openssl version
LibreSSL 2.8.3
$ brew update
$ brew reinstall openssl
$ brew link --force openssl
$ echo 'export PATH=$(brew --prefix openssl)/bin:$PATH' >> ~/.zshrc
$ source ~/.zshrc

openSSLのパスを通した状態でbrew info opensslを実行、パスが通っているのを確認

brew info opensslに記載されている、以下部分でパスを通す

For compilers to find openssl@3 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
  export CPPFLAGS="-l/usr/local/opt/openssl@3/include"
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl@3/lib"

その後、bundle installでmysql2がインストールできたことを確認

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0