2
0

More than 3 years have passed since last update.

git push heroku masterでruby-2.6.5 on heroku-20とエラーが出た件

Posted at

はじめに

今回はHerokuでのデプロイの際に以下のようなエラーが出たので解決策を記録しておこうと思います。

ターミナル
remote:  !
remote:  !     The Ruby version you are trying to install does not exist on this stack.
remote:  !     
remote:  !     You are trying to install ruby-2.6.5 on heroku-20.
remote:  !     
remote:  !     Ruby ruby-2.6.5 is present on the following stacks:
remote:  !     
remote:  !     - cedar-14
remote:  !     - heroku-16
remote:  !     - heroku-18
remote:  !     
remote:  !     Heroku recommends you use the latest supported Ruby version listed here:
remote:  !     https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote:  !     
remote:  !     For more information on syntax for declaring a Ruby version see:
remote:  !     https://devcenter.heroku.com/articles/ruby-versions
remote:  !

開発環境

  • Ruby 2.6.5
  • Bundler 2.1.4
  • Rails 6.0.0
  • MySQL 5.6.50

解決方法

結論から言うとHerokuのstackruby 2.6.5に対応していないのが原因です。
今回の場合だと、stack-20が対応していないので、stackのバージョンを下げることで解決できます

エラー分の真ん中あたりにも
heroku-16
heroku-18などと提案してくれているので、stack-18にバージョンを下げます。

ターミナルで以下のコマンドを実行します。

ターミナル
% heroku stack:set heroku-18 -a アプリ名
# 以下のように出力されれば成功
Setting stack to heroku-18... done

次にheroku apps:infoコマンドでバージョンを確認してみましょう。

ターミナル
% hroku apps:info
=== my_app
Addons:         cleardb:ignite
Auto Cert Mgmt: false
Dynos:          
Git URL:        https://git.heroku.com/my_app.git
Owner:          メールアドレス
Region:         us
Repo Size:      0 B
Slug Size:      0 B
Stack:          heroku-18
Web URL:        https://my_app.herokuapp.com/

stackがheroku-18になっていることを確認しましょう。

ここまで来たら、Commit履歴を残しておくといいでしょう。

ターミナル
% git commit --allow-empty -m "Downgrading to heroku-18"

ターミナルで以上のコマンドを実行するとGitにCommit履歴が残っているので、pushしておきましょう。

ここまで来たらHerokuにpushしてデプロイしましょう。
git push heroku masterをターミナルで実行し、デプロイをしましょう。

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