LoginSignup
1

More than 1 year has passed since last update.

Rails6 Heroku デプロイで発生したエラーとその対処法

Posted at

RubyとRailsの最新の安定版(2022年6月14日現在での最新の安定版)でherokuへのデプロイを行なった。
その際に発生したエラーをまとめてみました。

環境

  • mac OS
  • ruby 3.1.2 (2022年6月14日現在での最新の安定版)
  • rails 6.1.6 (2022年6月14日現在での最新の安定版)
  • node 16.13.0 (12以上にしといたほうがいいらしい)
  • yarn 1.22.19 (1以上にしといたほうがいいらしい)

発生したエラー

Failed to install gems via Bundler

このエラーはgit push heroku mainコマンドを実行したときに発生。
下記記事の通りでうまくいく。
(https://qiita.com/m6mmsf/items/fb8a8672df98bdb59c9c)

you don't have net-smtp installed in your application. please add it to your gemfile and run bundle install

このエラーはデプロイが成功した後、heroku run rails db:migrateを実行すると発生する。
エラー文の通りに必要なgemをインストールすると治るが、追加で必要なgemがある。

gem 'net-smtp'
# 下の二つも追加したほうがいいらしい
gem 'net-imap'
gem 'net-pop'

上記のように編集しbundle install を実行する。

注意点

アプリケーションに変更を加えた場合は、

  • git add
  • git commit
  • git push heroku ブランチ名

の3つを実行しないと本番環境に変更が反映されないので注意。
このエラーに関しては詳しくは下記記事。
(https://qiita.com/jnchito/items/4ef331281f0050428716)

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
1