LoginSignup
0
0

More than 1 year has passed since last update.

bundle install 時にmysql2のインストールがエラーになる

Posted at

bundle install時にだいたいmysql2のインストールがエラーになるのでメモ
※M1 mac book airにて動作

大体こんなエラーが出る

Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling.

open sslの設定が必要なので、以下の順番に調べて設定

$ brew info openssl
openssl@1.1: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/openssl@1.1/1.1.1k (8,071 files, 18MB)
  Poured from bottle on 2021-05-12 at 21:01:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/openssl@1.1/certs

and run
  /opt/homebrew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"        ← ここが重要
  export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include".  ← ここが重要

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"

==> Analytics
install: 803,075 (30 days), 2,624,782 (90 days), 8,822,713 (365 days)
install-on-request: 62,439 (30 days), 260,077 (90 days), 1,146,614 (365 days)
build-error: 0 (30 days)

上の調べた結果を設定して解決

$ bundle config --local build.mysql2 "--with-cppflags=-I/opt/homebrew/opt/openssl@1.1/include"
$ bundle config --local build.mysql2 "--with-ldflags=-L/opt/homebrew/opt/openssl@1.1/lib"
0
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
0
0