0

I am trying to deploy a Django app via Heroku for the first time.

When I run git push heroku master it returns this error:

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:  !
remote:  ! ## Warning - The same version of this code has already been built: e6acd22b123b939729546f4f06f368a8855a4744
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version e6acd22b123b939729546f4f06f368a8855a4744
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !       Push rejected to vygrapp.
remote: 
To https://git.heroku.com/vygrapp.git
 ! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vygrapp.git'

Following similar problems on SO I believe I have my file structure correctly configured - with git deployed from same place as my Procfile etc. I also have a requirements.txt file which I believe tells Heroku it's a python app - so I can't figure out why the buildpack isn't working.

Based on comments and feedback I moved all folders into root directory but receive the same error.

enter image description here

deadant88
  • 920
  • 9
  • 24

1 Answers1

0

Heroku only looks for your Procfile, requirements.txt, and runtime.txt in the root directory of your project. Move them up a level so they're beside your .gitattributes.

That should let Heroku detect that this is a Python project and get past the current error.

But your project still won't run. Out of the box, Heroku will expect your Django project to also be in the root directory of your repository. You can probably get it to work from a subdirectory by playing around with the DJANGO_SETTINGS_MODULE environment variable and / or PYTHONPATH, but the easiest solution is to move your entire project up a directory.

I suggest you move everything from anybody/anybody1/ to anybody/, then delete the now empty anybody/anybody1/ directory.

Then commit, and redeploy.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Thank you for your response - I've followed your instructions and deleted the ``anybody1`` directory - although one remains with ``settings`` etc in it. Here is what my directory [looks like now](https://ibb.co/bvpVJhP). The error is still thrown though. – deadant88 Jan 12 '22 at 03:57
  • You're getting the _same_ error? What directory contains your `.git/` folder? – ChrisGPT was on strike Jan 13 '22 at 03:11
  • Thanks for the reply! [Here](https://ibb.co/QdrHs0f) is my folder structure with `.git/` unhidden - you can see there are two `.git/` folders in different directories - perhaps a clash? Apologies for the screenshot, a bit inelegant. – deadant88 Jan 13 '22 at 09:10
  • [Nesting Git repositories probably doesn't do what you think it does](https://stackoverflow.com/q/1871282/354577). In any case, which repository are you pushing to Heroku? – ChrisGPT was on strike Jan 13 '22 at 19:50
  • Sorry for my ignorance - how do I check this? First time deploying. – deadant88 Jan 13 '22 at 21:41
  • How are you deploying? Via `git push`? GitHub integration? – ChrisGPT was on strike Jan 13 '22 at 21:45
  • `git push` following [this tutorial](https://realpython.com/django-hosting-on-heroku/#step-6-create-a-heroku-app) `git remote -v` results in `heroku https://git.heroku.com/vygrapp.git (fetch) heroku https://git.heroku.com/vygrapp.git (push)` – deadant88 Jan 13 '22 at 22:00
  • And what directory are you in when you run `git push`? – ChrisGPT was on strike Jan 13 '22 at 22:02
  • `programming/projects/anybody` – deadant88 Jan 13 '22 at 22:32
  • And you've committed the change where you moved the files? You are _definitely_ pushing a commit where your `Procfile`, `requirements.txt`, `runtime.txt`, and your main Django project are all in that directory? – ChrisGPT was on strike Jan 13 '22 at 22:38
  • I believe so - [here](https://ibb.co/SVYv5mg) is the result of running `git status`, I ran `git commit` to 2x check too [here](https://ibb.co/DG5bH58) is the last log. – deadant88 Jan 13 '22 at 22:59
  • Please share text as text, not images. And ideally all of this would go into your question. Has the error message changed at all? – ChrisGPT was on strike Jan 13 '22 at 23:12
  • Will do from now, I suppose I'm not sure how deep the problem goes. The error message had not changed. – deadant88 Jan 13 '22 at 23:30
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/241054/discussion-between-deadant88-and-chris). – deadant88 Jan 13 '22 at 23:32