3
2

More than 3 years have passed since last update.

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.と出てきたときの対処法②

Last updated at Posted at 2020-01-02

最近の勉強で学んだ事を、ノート代わりにまとめていきます。
主に自分の学習の流れを振り返りで残す形なので色々、省いてます。
Webエンジニアの諸先輩方からアドバイスやご指摘を頂けたらありがたいです!

bundle installを実行した際に起きた出来事

このエラーは、ごくたまに遭遇するのですが、mysql2がインストールしてる際に上手くインストールできない場合に発生するみたいです。

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.

In Gemfile:
  mysql2
         run  bundle binstubs bundler
Could not find gem 'puma (~> 3.11)' in any of the gem sources listed in your Gemfile.
         run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install

エラーで言われている通りに、以下のコマンドを実行したのですが...

$ gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'

変わらず同じエラーが...
解決策を調べて試していた所、そもそもちゃんとmysqlが動かないことを確認

$ mysql.server start
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/XXXXXXXX.local.pid).

まずは、mysqlをスタートさせようとしたがこちらもエラーが直らないので
この記事を参考に再インストール!

mysqlがどうしても起動しない - Qiita

記事の通りに /usr/local/var/mysql も削除し

$ sudo rm -rf /usr/local/var/mysql
$ brew uninstall mysql
$ brew install mysql

で、試してみると…


mysql.server start
Starting MySQL
 SUCCESS! 

成功し、試しにbundle install もした所こちらも成功した!
そもそも、ちゃんとsqlが動いてなかったのが原因かもしれないです。

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