LoginSignup
26
11

More than 5 years have passed since last update.

RailsでMySQLのbundle installエラー対処方

Posted at

Railsでmysqlを使おうとした際に以下のようなエラーが出て困ったのでその対処法を記してみます。
あくまでも参考程度にみてください。

Gem files will remain installed in /Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.4 for inspection.
Results logged to /Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.4/gem_make.out

An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue.
Make sure that 'gem install mysql2 -v '0.4.4'' succeeds before bundling.

翻訳してみると
Gemファイルは、/Users/user_name/Programs/web/testrepo/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.4 にインストールされたままになります。結果は /Users/user_name/Programs/web/test-repo/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.4/gem_make.out に記録されます。

mysql2(0.4.4)のインストール中にエラーが発生し、Bundlerを続行できません。
バンドルする前に 'gem install mysql2 -v' 0.4.4 ''が成功していることを確認してください。

とりあえずgem install mysql2 -v '0.4.4'でインストールを試みる。しかし、再び同じエラーが表示され、bundle install → error → gem install... 以下ループ...

解決しないじゃねーか!!!!!
ということで僕が解決した手順を書き残しておきます。
あくまでも解決した一例です

解決手順

1.bundlerの構成オプションを設定する

ローカル指定

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.プロジェクト配下にbundle install

bundle installを行う際にinstall pathをプロジェクト配下のディレクトリーに指定する。

bundle install --path vendor/bundle
26
11
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
26
11