症状
git push heroku masterをしたところ、下記エラーメッセージが表示されてしまい、herokuにpushできませんでした。gitpushherokumaster
git push heroku master
Counting objects: 219, done.
Compressing objects: 100% (193/193), done.
Writing objects: 100% (219/219), 3.96 MiB | 2.48 MiB/s, done.
Total 219 (delta 70), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.15
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.6.3.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3.
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.6.3.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3.
remote:
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.3 on heroku-20.
remote: !
remote: ! Ruby ruby-2.6.3 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: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: e4e8b0a69aeb09b76275b11e90d4096eb832212c
remote: !
remote: ! We have detected that you have triggered a build from source code with version e4e8b0a69aeb09b76275b11e90d4096eb832212c
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to murmuring-headland-65418.
remote:
To https://git.heroku.com/murmuring-headland-65418.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-headland-65418.git'
翻訳すると、「インストールしようとしているRubyバージョンはこのスタックに存在しません。」
「エラー:一部の参照を「https://git.heroku.com/herokuname-12345.git」にプッシュできませんでした」
解決方法
Gemfileのrubyをしている箇所をコメントアウトすることで、上記エラーが表示されなくなりました。herokuがruby2.6.3をサポートしていなかったようです。
Gemfile
# ruby '2.6.3'
ターミナル
#bundleinstallしておく
bundle install
#gitにpushしておく
git add -A
git commit -m "changeGemfile"
git push heroku master