LoginSignup
3
1

More than 1 year has passed since last update.

macOSのrailsで"An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue."の対処方法

Last updated at Posted at 2021-08-31

環境

macOS Big Sur(11.2)
ruby
rails6.1.4
mysql2

gemでmysql2インストール時、絶対errorに俺はなる

以前はQiitaに対処方法のエントリがあったのだけど、なんか無くなっちゃったので。

Gem::Ext::BuildError: ERROR: Failed to build gem native
extension.
.....
An error occurred while installing mysql2 (0.5.3),
and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.3' --source
'https://rubygems.org/'` succeeds before bundling.

解決法

ターミナルで下記を打ち込む。

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

Gemfileに下記をかいて、bundle installする。

Gemfile
gem 'mysql2', '~>0.5.3'

以上です。

3
1
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
3
1