0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

databaseをmysqlにした後bundle installでエラーになる件

Posted at

※備忘録

問題

databaseをmysqlに変更したあと、Railsでアプリ作成をする際に、エラーが出た。

実行コマンド

$ rails _5.2.4_ new app_name --skip-coffee --database=mysql
gem 'pry-rails'
$ bundle install

エラー内容

(省略)
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/fengjianlengfu/.rbenv/gems/2.6.0/gems/mysql2-0.5.3 for
inspection.
Results logged to
/Users/fengjianlengfu/.rbenv/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.3/gem_make.out

やったこと

・ログ内容のコマンドを実行(解決できなかった)

gem install mysql2 -v '0.5.2'

・似たエラーを出している人の解決策を探す

この方が書かれていることを参考にするとエラーなくインストールできた。

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

わかったこと

・この部分が原因だった模様。

ld: library not found for -lssl

・上記のエラーはsslというライブラリが読み込めてない時に起こる。
→ライブラリが存在しないかライブラリへの接続リンクが間違っている。

$ bundle config --localはローカルのアプリケーションに対して設定を行っている。
参照1 参照2

感想

正直、なぜこの方法で解決できたのかなど理解できていない。
今後学習をしていく中で振り返っていきたい。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?