サーバレスのサムネイル

サーバレス

Herokuで「No default language could be detected for this app.」とエラーがでた時の対応

公開日: 2019.11.23

HerokuでPHPアプリをデプロイした時に「No default language could be detected for this app.」というエラーが出てデプロイができなかった場合の、原因と対応策をまとめました。

編集ノート: SERVERSUSでは、パートナーリンクからコミッションを得ています。コミッションが記事の意見や、サービスの評価に影響を与えることはありません。

「No default language could be detected for this app.」エラーとは?

herokuにアプリをデプロイするときに、

git push heroku master

こんなエラーがでる時があります。

remote: Compressing source files... done.
remote: Building source:
remote:
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 c-reviewmark-xyz.
remote:

これは、Heroku側でそのアプリがなんの言語で書かれているかが判定できなかった時に出るエラーです。

通常は、PHPやらRubyやら自動で判定されるのですが、何かが原因で判定できてません。

原因と解決方法

判定できないならと、管理画面からBuildpackを入れてみて、デプロイしてみると原因がわかったりします。今回はPHPアプリです。

remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/php.tgz
remote:
remote:  !     ERROR: Application not supported by this buildpack!
remote:  !
remote:  !     The 'heroku/php' buildpack is set on this application, but was
remote:  !     unable to detect a PHP codebase.
remote:  !
remote:  !     A PHP app on Heroku requires a 'composer.json' at the root of
remote:  !     the directory structure, or an 'index.php' for legacy behavior.
remote:  !
remote:  !     If you are trying to deploy a PHP application, ensure that one
remote:  !     of these files is present at the top level directory.
remote:  !
remote:  !     If you are trying to deploy an application written in another
remote:  !     language, you need to change the list of buildpacks set on your
remote:  !     Heroku app using the 'heroku buildpacks' command.
remote:  !
remote:  !     For more information, refer to the following documentation:
remote:  !     https://devcenter.heroku.com/articles/buildpacks
remote:  !     https://devcenter.heroku.com/articles/php-support#activation
remote:
remote:
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed

また、エラーです。

ログを見てみると、原因が書いてあります。

A PHP app on Heroku requires a 'composer.json' at the root of the directory structure, or an 'index.php' for legacy behavior.

つまり、「アプリルートにcomposer.jsonかindex.phpがないとダメだよ」ということですね。このアプリではindex.phpもcomposer.jsonもなかったためエラーでした。


「No default language could be detected for this app.」エラーの原因を探る方法と対策をみてきました。

しっかりとドキュメントを読めばわかることなのですが、簡単にエラー原因を探りたいのであれば、Buildpackを自分でインストールしてみて、デプロイすると原因がログから見つかるということを覚えておきましょう。


価格は記載がある場合を除き、すべて税込みです。

関連キーワード

サーバレスの新着記事