LoginSignup
24
10

More than 1 year has passed since last update.

Herokuでgit push heroku masterした時にrejectされたら見る記事

Last updated at Posted at 2020-04-22

herokuでgit pushしたらrejectされた時の対処

gitに不慣れなのに頑張ってherokuを使おうとしてpushしたらrejectedと言われて何が悪いのかわからない時に見る記事です

コメント、いいね大歓迎です。誤字や間違いは指摘していただけると助かります
注 masterではなくmainとなっている人は記事内のmasterと書かれている部分を読み替えてください。

rejectの原因はどこに書いてあるのか

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 212 bytes | 212.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !	Push rejected to project.
remote: 
To https://git.heroku.com/project.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project.git'

例えばこの例だと真ん中の方の

App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz

この文章がエラーの内容です

ここからはこれを踏まえてエラーの種類ごとに見ていきます。

App not compatible with buildpack

No default language could be detected for this app.

この二つのメッセージはherokuが「何の言語でどんな依存関係を持っているのかわからん」と言っています。

この場合はリポジトリのルートディレクトリに言語ごとに決まったファイル名のファイルを配置する必要があります。そのファイルには依存関係が記述されます。
※ルートディレクトリはgit initを実行した場所で、.gitという隠しフォルダがある場所です
中身がなくても空のファイルを配置してください。
既にファイルあるよという場合は記述ミスの可能性もあります。

言語ごとに必要なファイル

PHP

composer.json

Node.js

package.json

Ruby

Gemfile

Python

requirements.txt

Go

Godeps/Godeps.json 又は vendor/vendor.json 又は srcと言う名の.goファイルを一つ以上含むディレクトリ

Scala

sbt.versionプロパティーを持つ/project/build.propertiesと言う名のファイル

java

pom.xml

Clojure

project.clj

non-fast-forward

前にpushした内容とgitの履歴が噛み合わない時に出ます。気にしないのであれば強制的に

git push heroku master -f

request runtime not available

runtime.txtがちゃんとルートディレクトリにあるかを確認
runtime.txtに指定されているランタイムがサポートされてない可能性があるので他のバージョンを試す

参照
https://devcenter.heroku.com/categories/language-support

24
10
1

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
24
10