heroku「error: failed to push some refs to」の対処したときの備忘録

プログラミング

herokuで作成したアプリケーションですが、migration周りのエラーが解消できず・・・。

相談できる人も周りにおらず、エラー内容でググっても答えが見つからなかったので、herokuのアプリケーションを再作成することにしました。

destoryでアプリケーションを削除してから、createしました。

その後に「git push heroku master」を行ったのですが、デプロイ時にエラー。

 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hogehoge.git'

対処方法(結論)

heroku ps:scale web=1

上記をターミナルで実行後、「git push heroku master」でデプロイが通りました。

1時間くらい格闘していたと思います。うわあああ疲れた。

解決のヒントとなったところ

herokuの管理画面で「Activity」の項目があると思います。

そこにエラーログが書かれているのですが、そちらがヒントになりました。

 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_c955307cefc42188045b55f5e3fa0b34/static'
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed

ちゃんと「heroku config:set DISABLE_COLLECTSTATIC=1」をやれと書かれていますね・・・。

エラーはよく見るようにいたします。

試したこと

git push origin :branch-name
git push origin branch-name

こちらのqiitaの記事に似た問題に合われた方がいるようでしたが。試したところ解決には至らず。

https://qiita.com/yoshixj/items/6441ab2cd6bc367e607d

他にも「git push」で-fコマンドを使って強制デプロイしましたが、こちらも失敗。

今思えばherokuの権限周り問題だったのかなと思います。

であれば、オプションを変更して解決できるってことは考えにくいですね。

本当に、エラーはよく見るようにします。