LoginSignup
78
42

More than 3 years have passed since last update.

Railsの環境構築時にLibrary not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)で苦しんだ

Last updated at Posted at 2020-02-09

Railsの環境構築時に表題のエラーで苦しんだ

おなじみのopensslのエラー。どうせすぐ解決できるやろって思ってたら意外とハマったので備忘録として残しておきます。

bundleを叩くとコケる

諸々の環境構築終了後によしローカルサーバー立ち上げるぞ!と意気揚々と

$ bundle exec rails s

を叩くと

Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /usr/local/opt/mysql@5.6/lib/libmysqlclient.18.dylib
  Reason: image not found - /Users/~~/~~/~~/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle

あれ、opensslで怒られてるぞ…

https://qiita.com/YoshiyukiKato/items/e4f67c588d2943c1253d
この方の記事の通り、

$ brew install openssl
$ brew link openssl --force
$ rbenv uninstall 2.5.5
$ rbenv install 2.5.5

とかでいけるやろ… いけー!!

Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /usr/local/opt/mysql@5.6/lib/libmysqlclient.18.dylib
  Reason: image not found - /Users/~~/~~/~~/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle

え…同じじゃん…

というわけで少しハマってしまいました…

解決法

https://qiita.com/utsu_jimmy/items/a35437faea1c0d2f357d
この方の記事も参考にしながら、rbenvでrubyごと再インストールしたり、brew upgrade試したり一通りはやったのですが、エラー内容は変わらず…

もしかしてopensslのversionがおかしい?と思って、

$ brew switch openssl ~~

みたいにopensslのversionを切り替えようとすると

Error: openssl does not have a version ~~ in the Cellar.
openssl's installed versions: 1.0.2s

あ、~~なんてversionなかった。。。じゃあ1.0.2s指定したったらどうなるんやろ

$ brew switch openssl 1.0.2s

を実行すると、、

Cleaning /usr/local/Cellar/openssl/1.0.2s
Opt link created for /usr/local/Cellar/openssl/1.0.2s

ん?もしかしてうまくいった?
じゃあこれで

$ bundle exec rails s

実行すると

=> Booting WEBrick
=> Rails 5.1.7 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options

ふつうに立ち上がったあああ!

結局opensslのversionが問題だったようです…

記事にするとしょうもないけど、ハマるときはハマりますよね…

この記事が誰かの役に立てば幸いです

78
42
2

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
78
42