LoginSignup
3
0

More than 1 year has passed since last update.

【Rails】HerokuからSlack APIにアクセスするとSSL_CTX_load_verify_file: system libというエラーが起きる場合の対処法

Last updated at Posted at 2022-10-03

2023-5-2追記
この記事の内容はslack-ruby-client 2.1.0を使うことで解決することを確認しました。
よってheroku-20にダウングレードする必要はありません。

発生した問題

ローカルでは問題なく動いていたRailsアプリをHerokuにデプロイすると、Slack APIにアクセスするタイミングで以下のようなエラーが発生しました。

ActionView::Template::Error (SSL_CTX_load_verify_file: system lib):
    1: channels = slack_client.channels

このエラーが発生した環境は以下のとおりです。

  • Ruby 3.1.2
  • Rails 7.0.4
  • slack-ruby-client 1.1.0
  • heroku-22 stack

原因

下記のredditにほぼ同じ現象が載っていました。

Having issues installing Ruby : ruby

Hey OP: I'm running into the same SSL_CTX_load_verify_file: system lib error using Ruby 3.1.2 and the Slack gem (1.0.0). I should also specify I'm seeing the error on Heroku, whereas local certs are loading as expected. Were you able to get this working?

(略)

Turns out, I've mitigated this by downgrading Heroku stack to 20. Stack 22 is built on Ubuntu 22.04, using OpenSSL 3.0.2, which is why I received this error. Thanks for your reply!

上のコメントにもあるとおり、Ruby 3.1.2とheroku-22 stackを使っているとこの問題が起きるようです。

Screen Shot 2022-10-03 at 9.23.16.png

対処法

redditには「heroku-20 stackなら動いた」とあるので、本来はあまり望ましくないですが、この問題が解決するまでheroku-20 stackを使うことにします。

heroku stack:set heroku-20 --app your-awesome-app

設定変更が終わったら何らかのコミットを行い、再デプロイしてください。
以下の例ではコードを変更せず、空のコミットを作成してherokuにpushしています。

git commit --allow-empty -m "downgrade stack"
git push heroku main

stackがheroku-20に戻っていれば正常にSlack APIにアクセスできるはずです。

Screen Shot 2022-10-03 at 9.27.05.png

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