LoginSignup
0
2

More than 3 years have passed since last update.

#エラー解消 RailsでMySQL bundle install エラー

Last updated at Posted at 2019-09-08

RailsでMySQLを使ってみた時に出たエラー

DBの指定はrails new時点で、DBをデフォルトのSQLiteからMySQLに指定することが可能ですがしていなかったので、
途中からDBをMySQLに指定しようとしたら出たエラーです。

したこと

Gemfileに gem 'mysql2'と記述し、bundle installをした。

エラー

bundle install後にエラー

エラーメッセージ
Gem files will remain installed in
/Users/*ユーザー名*/*ペアレントディレクトリ名*/*カレントディレクトリ名*/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection.
Results logged to
/Users/*ユーザー名*/*ペアレントディレクトリ名*/*カレントディレクトリ名*/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/mysql2-0.5.2/gem_make.out

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

解決コマンド

bundle config --local build.mysql2 --with-opt-lib=/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include
bundle config build.mysql2 --with-opt-lib=/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include

2つともしてください。

もう一回

Gemfileにgem 'mysql2'と記述し、bundle install --path vendor/bundle

メッセージ

Installing mysql2 0.5.2 with native extensions
Bundle complete! 19 Gemfile dependencies, 79 gems now installed.
Gems in the group production were not installed.
Bundled gems are installed into `./vendor/bundle`

解決〜!!
Qiita記事の方に感謝。

参考にした記事

0
2
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
2