如何解决Heroku中的“推送被拒绝,没有检测到Cedar支持的应用”错误

1 投票
1 回答
2717 浏览
提问于 2025-04-18 00:59

这是我的 Django 项目结构:

Testing
|_djangoApp
|_Testing
| |-- __init__.py
| |-- settings.py
| |-- urls.py
| |-- utils.py
| |-- wsgi.py
|
|_manage.py
|_Procfile
|_requirements.txt
|_README.md

我正在使用 codeship.io 来部署构建,并将其推送到 Heroku,这个配置得很好。在 Heroku 上,我创建了一个名为 "Testing" 的应用。

我尝试通过 codeship 将构建推送到 Heroku,但出现了以下错误:

 !     Push rejected, no Cedar-supported app detected

To git@heroku.com:Testing.git
! [remote rejected] feca277a98c193c3b338ee1bd1406e6bc8f6b9e7 -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:Testing.git'

Procfile 的内容:

web: gunicorn Testing.wsgi

requirements.txt 的内容:

Django==1.3.1
docutils==0.8.1
psycopg2==2.4.2
Fabric==1.3.2
South==0.7.3
gunicorn==0.13.4
newrelic==1.0.5.156
django-celery==2.4.2
django-kombu==0.9.4
django-storages==1.1.3
boto==2.1.1
pylibmc==1.2.2
django-pylibmc-sasl==0.2.4
django-sorting==0.1
django-guardian==1.0.3
django-pagination==1.0.7
pyst2==0.4
django-annoying==0.7.6
django-tastypie==0.9.11
django-coverage==1.2.1
django-nose==0.1.3
nosexcover==1.0.7
django-debug-toolbar==0.8.5
Sphinx==1.1.2
django-cache-machine==0.6
django-twilio

我刚刚从我的 Bitbucket 私有仓库克隆了我的项目,并添加了 Procfile 以使其与 Heroku 兼容。我尝试按照官方文档进行操作,但文档只关注从头开始的内容。我在这里漏掉了什么?需要帮助!

1 个回答

1

现在问题解决了,但关于如何把一个预先构建好的 Django 项目部署到 Heroku 的说明实在是太难懂了,我想在这里解释一下:

假设你的文件夹结构是这样的:

Testing
|_djangoApp
|_Testing
| |-- __init__.py
| |-- settings.py
| |-- urls.py
| |-- utils.py
| |-- wsgi.py
|
|_manage.py
|_requirements.txt
|_README.md

你可以在命令行中运行: python manage.py runserver

但是 Heroku 需要一个叫 Procfile 的文件,而不是 ProcFile.txt 文件,才能运行你的 Django 项目。

现在,在你放有 requirements.txt 的同一个文件夹里添加一个 Procfile,并按照下面的格式编辑(记得注意空格哦)

web: gunicorn Testing.wsgi -b 0.0.0.0:$PORT

基本的 requirements.txt 文件应该包含:

Django==1.4
simplejson==2.2.1
lxml==2.3.5
pyyaml==3.10
fabric==1.4.3
unittest2==0.5.1
mock==1.0b1
psycopg2==2.4.5
dj-database-url==0.2.1
gunicorn==0.14.6
gevent==0.13.7
greenlet==0.4.0
boto==2.5.2
django-storages==1.1.5
django-ses==0.4.1 #remove this if you don't use Amazon SES
redis==2.7.1
django-celery==3.0.11
South==0.7.6

现在把这些推送到你的 heroku 账户。

还有一点,如果你想把 Bitbucket 的代码库推送到 Heroku,你可以使用 codeship.io 作为中间工具。

每次你从本地代码库推送时,Heroku 环境会自动部署一个新的版本。

撰写回答