mysql2のgemパッケージを使用しているRails5プロジェクトで、 bundle install
しようとすると以下のエラーがでる
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.
いろいろ、試しましたが以下の方法で解決しました。
Railsのプロジェクトで以下を実行
$ bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
すると、.bundle/configに以下が生成される。
BUNDLE_BUILD__MYSQL2: "--with-ldflags=-L/usr/local/opt/openssl/lib"
再度、 bundle install
$ bundle install
無事、インストールされました。
コメント