git Heroku 中“Procfile 声明类型 -> (none)”的原因是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6346221/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the reason for "Procfile declares types -> (none)" in Heroku?
提问by Jason Kuhrt
I am trying to deploy a test app to Heroku --stack cedar but every time I do my Procfile is being ignored.
我正在尝试将测试应用程序部署到 Heroku --stack cedar,但每次我执行 Procfile 时都会被忽略。
It should be saying this:
应该是这样说的:
Procfile declares types -> web
But says this
但是说这个
Procfile declares types -> (none)
Because of this problem it of course won't load on the heroku platform when I navigate the URL.
由于这个问题,当我浏览 URL 时,它当然不会加载到 heroku 平台上。
Aside from this test (A) I have an IDENTICAL project (B) in another folder which DOES work. I am so utterly confused as to why (A) doesn't that I'm coming here to ask now.
除了这个测试 (A) 我在另一个文件夹中有一个相同的项目 (B),它确实有效。我很困惑为什么(A)没有,我现在来这里问。
A couple other things I've tried with (A) include:
我尝试过的其他一些事情(A)包括:
- recreating the heroku app
- recreating the git repo (i.e. delete .git, git init...)
- clearing out the files from the project folder, and copying the files from the other copy that works
- 重新创建 heroku 应用程序
- 重新创建 git repo(即删除 .git、git init...)
- 从项目文件夹中清除文件,并从另一个有效的副本中复制文件
If I make top-level folder copy of (B) then that copy will work. The issue seems to be copying files/folders from within (B) et al to within (A), the cursed one.
如果我制作 (B) 的顶级文件夹副本,那么该副本将起作用。问题似乎是将文件/文件夹从 (B) 等复制到 (A) 中,这是被诅咒的。
So, so far all I can determine is everything is working minus this (A) cursed folder. I would love to find out why instead of having to come to a witch-craft conclusion.
所以,到目前为止,我所能确定的是一切正常,减去这个 (A) 被诅咒的文件夹。我很想找出原因,而不必得出巫术结论。
回答by Pascal Lindelauf
I had the same problem and I just now I found what was wrong. I first accidently called the file ProcFile
instead of Procfile
. Simply renaming that file did not get picked up by git. I had to do a git rm ProcFile -f
first and then add a new (correctly named) Procfile
. After that, it got pushed correctly by git and got picked up correctly by Heroku.
我遇到了同样的问题,我刚刚发现了问题所在。我首先不小心调用了文件ProcFile
而不是Procfile
. git 不会简单地重命名该文件。我必须先做一个git rm ProcFile -f
,然后添加一个新的(正确命名)Procfile
。之后,它被 git 正确推送并被 Heroku 正确接收。
回答by Deepak Ram
Make sure your Procfile does not have any extension.And if it has any you have to rename that file to Procfile without any extension and commit and check out the master
确保您的 Procfile 没有任何扩展名。如果有任何扩展名,您必须将该文件重命名为 Procfile 没有任何扩展名并提交并检查主文件
回答by johnsq
Did you remember to commit your Procfile
to git? I've forgotten to do this commit, done a git push heroku master
, and seen the (none)
message stated above.
你记得把你的提交Procfile
给 git 吗?我忘了做这个提交,做了一个git push heroku master
,并看到了(none)
上面提到的消息。
If you've forgotten, then commit your Procfile
and perform git push heroku master
again.
如果您忘记了,请提交Procfile
并git push heroku master
再次执行。
回答by thadk
The space between the Record name and the contents seems to be important:
记录名称和内容之间的空格似乎很重要:
Use:
用:
web: python manage.py runserver
web: python manage.py runserver
and not
并不是
web:python manage.py runserver
web:python manage.py runserver
回答by Alon Gouldman
I'm adding to Pascal Lindelauf answer - make sure your file name is "Procfile" (with a capital P) and not "procfile" (that was the case with me just now) good luck!
我正在添加 Pascal Lindelauf 的答案 - 确保您的文件名是“Procfile”(大写 P)而不是“procfile”(我刚才就是这种情况)祝你好运!
回答by XinLiu
I have sth to say about "Procfile declares types -> (none)" error.
关于“Procfile 声明类型->(无)”错误,我有话要说。
One thing we should pay attention to is the hidden extension of "Procfile" file. I thought my command in "Procfile" was correct but I kept receiving this error. After half an hour I found that "Procfile" has the extension ".txt" but was hidden by the default setting of my macOS. After removing the extension, everything works fine!
我们应该注意的一件事是“Procfile”文件的隐藏扩展名。我认为我在“Procfile”中的命令是正确的,但我一直收到这个错误。半小时后,我发现“Procfile”的扩展名为“.txt”,但被我的 macOS 的默认设置隐藏了。删除扩展后,一切正常!
回答by Yash Marmat
this problem is mainly caused by the create Procfile command when it is run from the command prompt or terminal. I recommend you to create the Procfile manually.
此问题主要是由命令提示符或终端运行时 create Procfile 命令引起的。我建议您手动创建 Procfile。
If you are using Visual Studio code then, click on the pipfile and then on the upper side click the create new file
button and enter the name of the file as Procfile
.
如果您使用的是 Visual Studio 代码,请单击 pipfile,然后在上方单击create new file
按钮并将文件名输入为Procfile
.
Before doing this delete previous Procfile and also use the command git rm procfile -f
in command prompt in your active virtual environment.
在执行此操作之前,请删除之前的 Procfile,并git rm procfile -f
在活动虚拟环境中的命令提示符中使用该命令。
if you are using any other IDE then open notepad and enter this line in it
web: gunicorn mb_project.wsgi --log-file
-
after that save it as Procfile and put this file below your pipfile.
如果您使用任何其他 IDE,则打开记事本并在其中输入此行 web: gunicorn mb_project.wsgi --log-file
- 之后将其另存为 Procfile 并将此文件放在您的 pipfile 下方。
here is the link of my files https://github.com/YashMarmat/message-board-app.git
这是我的文件的链接https://github.com/YashMarmat/message-board-app.git
回答by Kinyua Kaigi
I had this error and tried all the solutions above but they did not work. Turns out that I had created the git repository in the root of the virtual environment. Which seems reckless but hey...
我遇到了这个错误并尝试了上述所有解决方案,但没有奏效。原来我已经在虚拟环境的根目录中创建了 git 存储库。这看起来很鲁莽,但是嘿...
So if you have tried all the solutions and they don't work check where you created your repository and make sure it is in the root of your project source code and not anywhere else.
因此,如果您尝试了所有解决方案但它们都不起作用,请检查您创建存储库的位置,并确保它位于项目源代码的根目录中,而不是其他任何地方。
回答by M3RS
I had this problem deploying a Django app to Heroku.
我在将 Django 应用程序部署到 Heroku 时遇到了这个问题。
- the git repository has to be initialised in the Django project root folder (where
manage.py
lives) - this is also where the
Procfile
needs to sit
- 必须在 Django 项目根文件夹(所在的位置
manage.py
)中初始化 git 存储库 - 这也是
Procfile
需要坐的地方
File structure:
文件结构:
Documents/
|---djangoprojectname/
| |---djangoprojectname/
| | |---__init__.py
| | |---settings.py
| | |---urls.py
| | |---wsgi.py
| |---djangoappname/
| |---.git
| |---manage.py
| |---Procfile
The Procfile
should look like this as per the docs:
根据文档Procfile
应该是这样的:
web: gunicorn djangoprojectname.wsgi
回答by Wolf
I was getting the same problem, and tried everything posted here. I was getting:
我遇到了同样的问题,并尝试了这里发布的所有内容。我得到:
Procfile declares types -> (none)
Instead of Procfile declares types -> web. My fix was to change in the regedit to 0 (tutorial here https://www.thewindowsclub.com/show-file-extensions-in-windows) and then deleting the .txt in the end of Procfile (So It was just a file with no extension). After that my problem was solved! You can check if you have solved doing the following commands in the cmd:
而不是 Procfile 声明类型 - > web。我的解决方法是将 regedit 更改为 0(此处的教程https://www.thewindowsclub.com/show-file-extensions-in-windows),然后删除 Procfile 末尾的 .txt(所以这只是一个没有扩展名的文件)。之后我的问题就解决了!您可以在cmd中执行以下命令检查是否已解决:
heroku ps
Should display something like:
应该显示如下内容:
=== web (Free): gunicorn app:app (1)
Or the git push:
或者 git push:
git push heroku master
And that should display:
这应该显示:
Procfile declares types -> web