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 3 years have passed since last update.

Ruby gem mysql2が `ld: library not found for -limported_openssl` で失敗する問題

Last updated at Posted at 2021-07-02

# 問題

gem install mysql2

するとき以下のエラーが出てきた:

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
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
...

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

解決

調べると、いろいろ方法がありそうですが(参考リンクは一番後ろに添付)、一番いい解決はopensslをインストール、エクスポートと思います:

brew install openssl
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

そうしたら

bundle install

無事解決しました。

参考資料

https://qiita.com/choripon/items/b59e568b614e7e67d1af
https://stackoverflow.com/questions/43523389/cannot-install-mysql2-gem-for-rails-project

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?