LoginSignup
5
1

More than 3 years have passed since last update.

herokuでbash: gunicorn: command not foundが出て動かなくなった件

Posted at

何がどうなったのかはわからない。

それまでは普通に動いていたものが、
あるとき
$ git push heroku master
したら動かなくなってしまった。

rest_frameworkを追加したり、色々している最中なので、原因はそれだと思う。
(ローカルでは問題なく動いている。)

フロント面ではherokuのエラー画面が出て

$ heroku logs --tail

してみろというので、言われるがまま確認したところ

2019-04-26T01:53:00.814411+00:00 heroku[web.1]: Starting process with command `gunicorn xxxxxx.wsgi --log-file -`
2019-04-26T01:53:02.370146+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-26T01:53:02.305820+00:00 app[web.1]: bash: gunicorn: command not found

「gunicornのコマンドが見つからない」とのこと。

確認してみると、確かにrequirements.txtにgunicornがない。

以前はあったはずなのだが…。

$ pip install gunicorn

をして

$ pip freeze > requirements.txt

requitements.txtを作りなおして再挑戦。

依然として直らない。

暗中模索していると

という記事を発見。

If you have both requirements.txt and Pipfile in the project root, then I would recommend to delete the Pipfile and have all your requirements listed in requirements.txt file (including gunicorn).

プロジェクトルートにrequirements.txtとPipfileが両方あるなら、Pipfileは削除した方が良いよ、と。

確認してみると、確かにPipfileとPipfile-lockが存在している。
意図して作ったものではないので、試行錯誤している時に勝手にできてしまったのだろう。

これらを削除し、requirements.txtを残した上で再挑戦。

直った。

5
1
0

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
5
1