Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heroku: no default language could be detected for this app

Tags:

python

heroku

First time using Heroku. Trying to push. I have run the command:

heroku create --buildpack heroku/python

and it displayed

$ heroku create --buildpack heroku/python
Creating app... done, glacial-reef-7599
Setting buildpack to heroku/python... done
https://glacial-reef-7599.herokuapp.com/ | https://git.heroku.com/glacial-reef-7599.git

Stack trace:

$ git push heroku master
Counting objects: 129, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (124/124), done.
Writing objects: 100% (129/129), 69.06 KiB | 0 bytes/s, done.
Total 129 (delta 22), reused 0 (delta 0)
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 pure-badlands-9125.
remote:
To https://git.heroku.com/pure-badlands-9125.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-badlands-9125.git'

I've gotta be missing something.

I have added a requirements.txt to my root directory. It looks like this:

.git
.idea
projectapp
projectname
rango
db.sqlite3
manage.py
populate_rango.py
requirements.txt
like image 702
Josh Laird Avatar asked Oct 05 '16 12:10

Josh Laird


People also ask

When Heroku Cannot detect the Buildpack to use for this application automatically?

Resolution. This error message means that Heroku was unable to automatically detect the type of app you're trying to deploy: Ruby, Node, Python, PHP, Java, etc. We look for signatures for each language we support (like a pom. xml file or package.

How does Heroku detect Buildpacks?

Buildpacks are composed of a set of scripts that will perform tasks such as retrieve dependencies or output generated assets or compiled code. If you are using a language that is officially supported by the Heroku platform, the build system will automatically detect which Heroku Buildpack is needed for the job.

How do you run NPM install on Heroku?

Run the npm install command in your local app directory to install the dependencies that you declared in your package. json file. Start your app locally using the heroku local command, which is installed as part of the Heroku CLI. Your app should now be running on http://localhost:5000/.


2 Answers

Quick Solution

  1. Goto heroku dashboard (https://dashboard.heroku.com/)
  2. go inside app/project
  3. click setting
  4. scroll down little bit and click add build pack
  5. select your desired buildpack (in my case i have selected heroku/nodejs).

TLDR;

Actually what heroku does is, it tries to identify what project you are deploying by looking at files in your project, such as if your project have package.json file it understands it is a nodejs project, if your project have requirements.txt file it understands it is a python project and so on, see this document to see to know what languages you can run on a heroku server

as you know to run a specific project such as a nodejs project in a computer node runtime must be installed in that computer otherwise you can not nodejs app in the computer, what heroku does it runs each of your app in a different container, it means in one container it is only one app is running and of course that container have installed nodejs, so if a container runs only one app it doesnt make sense to install all other runtimes in the container so container have only one runtime in my case it is nodejs. they have ofcourse other type of containers such as one type for python and that container have installed python runtime(of a specific version) so if my app gets installed in python container it will not work because my app in in nodejs. for this very reason somehow we need to identify the type of app in beginning to choose correct container type, mostly heroku automatically detect it but if it is failed to detect you have to tell explicitly either by going to their dashboard settings or through runtime file in your project, and as you may have noticed you have do this only once.

like image 70
Inzamam Malik Avatar answered Sep 20 '22 12:09

Inzamam Malik


For future references, you must ensure that you are pushing the branch with your code to heroku master.

If you branched from your master branch and all your code is on a, say, develop, push that to the heroku master.

So instead of:

git push heroku master

You would do something like:

git push heroku develop:master

This question has important details on this How to push different local Git branches to Heroku/master

like image 26
willieswanjala Avatar answered Sep 18 '22 12:09

willieswanjala