gitgithubherokuheroku-toolbeltheroku-cli

Heroku - the same code/repo deploys from GitHub but not from Heroku CLI (buildpack identification problem)


I have written a fairly simple Python/Django app, and wanted to deploy it to Heroku.

Since the project was tracked in GIT from day 1, my go-to strategy was to use Heroku CLI to deploy it. I have created all the necessary meta-files (Procfile, requirements.txt, Pipfile etc). I have also added all the necessary libraries and settings to my settings.py file (we can safely assume that everything is set up correctly, since the project was deployed and worked correctly in the end).

I have updated the Heroku CLI to the newest version. It seems to work correctly in all my "terminal" clients: PowerShell, GitBash, Termius.

And yet, when I try to perform the good 'ol "git push heroku master" the process is initiated, however it fails as it cannot determine the appropriate buildpack to use. Upon indicating the buildpack manually in Heroku settings, the CLI said the buildpack was not compatible:

PS C:\Users\mkokot\Dev\project-master> git push heroku master
Enumerating objects: 29, done.
Counting objects: 100% (29/29), done.
Delta compression using up to 8 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (29/29), 917.94 KiB | 114.74 MiB/s, done.
Total 29 (delta 12), reused 6 (delta 2)
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 myherokuapp.
remote:
To https://git.heroku.com/ciaplist.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myherokuapp.git'

Note: I changed project names/urls in the above example, I did not try to apply sample settings to this operation :)

Coming back to the "how do you know you configured everything correctly" issue: once I changed my strategy to deploying from GitHub, everything works like a charm, and buildpack is identified and executed correctly. However, I find this way of deployment cumbersome.

The question: Do you know why the same code might be accepted from GitHub but rejected from Heroku CLI? Where to look for errors/settings to modify? I would love to see "git push heroku master" work!


Solution

  • Ok so it was actually easy.

    When deploying to Heroku using the CLI, the Heroku toolbelt will always try to push your local repository's master branch to the heroku master repository. The code I got ready for deployment was in another branch.

    In order to push branch other than master to Heroku, you need to use:

    git push heroku your_branch_name:master

    More details: https://devcenter.heroku.com/articles/git#deploying-code

    Self-five!