LoginSignup
1
1

More than 3 years have passed since last update.

Heroku deploy error "No default language could be detected for this app."

Last updated at Posted at 2021-04-02

github上のアプリをherokuにデプロイしようとしたらエラー

~(省略)~

remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     No default language could be detected for this app.
remote:             HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:             See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to kero269map.
remote: 

~(省略)~

ヒントは「HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.」なので、buildpackを探しにBuildpacks | Heroku Dev Center に飛ぶ。

ダメだったポイント

1. builtpackがない

ビルドパックとは、"Buildpacks are responsible for transforming deployed code into a slug,"コードをナメクジにする役割をになっているらしいので、入れないとダメらしい。ニョロ。

ビルドパックは、(Third partyものもあるらしいが)同じページにあるOfficially supported buildpacksの中から選んで使った。一度セットすれば、そのアプリでプッシュするときは、そのビルドパックを使い続けられるらしい。

$ heroku buildpacks:set heroku/php ←phpの場合。pythonならheroku/python
※アプリcreateの時に同時に指定することもできる。その場合は、$ heroku create myapp --buildpack heroku/python
※removeは $ heroku buildpacks:remove heroku/nodejs

$ heroku buildpacks:set heroku/pythonしたら、Buildpack set. Next release on アプり名 will use heroku/python.Run git push heroku main to create a new release using this buildpack.というメッセージが出たのでgit push heroku mainしたら、またエラーが出た。

2. requirements.txtがない

App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgzがでた場合をググると、herokuで悩んだところ - Qiitaに「これはpushするファイルの中にrequirements.txtを作成していないのが原因でした。」とあるので、ふむふむと思うが。

requirements.txtってなに?中に何を書くの?ってレベルの私は、またググーる。するとrequirements.txtについて - Qiitaで作り方を教えてもらえる。(もちろん、デプロイしたいアプリがあるディレクトリで)以下の一行をぺろりと書けば、パッケージリストを記載したファイルを作ってもらえるのだ!

$ pip freeze > requirements.txt

※間違えてはいけないポイント。ファイル名はrequirementではなくrequirements!三単現のs必要です。
※私は、ファイル名だけ書き換えようとして、なぜだか全角で”s”と入れてしまい、その後延々と悩む羽目に…。

3. ファイル等を変更したのにcommitしていない

色々変更したくせに、commitせずにそのままgit push heroku mainすると、Duplicate build version detectedと怒られる。ちゃんとaddとかrmとかしてcommitする。

4. 現在のモジューに対するdistribituionがない

ipythonやらnumpyやら、とにかく複数のモジュールでERROR: No matching distribution found for モジュール名と言われてしまう。

ERROR: Could not find a version that satisfies the requirement traitlets==5.0.5 (from -r /tmp/build_b51bbc2a/requirements.txt (line 72)) (from versions: 0.0.1, 0.0.2, 4.0.0.dev0, 4.0.0, 4.1.0b1, 4.1.0, 4.2.0, 4.2.1, 4.2.2, 4.3.0b1, 4.3.0, 4.3.1, 4.3.2, 4.3.3.dev0, 4.3.3)
remote:        ERROR: No matching distribution found for traitlets==5.0.5 (from -r /tmp/build_b51bbc2a/requirements.txt (line 72))

もうやけくそで、記載のあるバージョンに変更。上の例のtraitletsならpip install traitlets==4.3.3にして、requirements.txtの該当箇所をtraitlets==4.3.3に変更。

ようやく"Deployed"の文字が見れた(涙)

==
別に無理してHeroku使う必要ないんだよなぁ…と思いながら、ムキになってやってしまった。エラーメッセージを読む良い練習になったけどさ。

膝の上で寝る犬のオナラが臭い。

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