[英]Git Heroku error [remote rejected] ... (pre-receive hook declined)
I'm trying to push my repo to my heroku stack but this error comes everytime up:我正在尝试将我的仓库推送到我的 heroku 堆栈,但每次出现此错误:
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
This is the full comandline log for Python version 3.8.0:这是 Python 版本 3.8.0 的完整命令行日志:
Enumerating objects: 36, done.
Counting objects: 100% (36/36), done.
Delta compression using up to 8 threads
Compressing objects: 100% (27/27), done.
Writing objects: 100% (36/36), 4.63 MiB | 923.00 KiB/s, done.
Total 36 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: /app/tmp/buildpacks/8790c95df255b386056ea169648fd4a33d1cb3fba81f73b536f26374f6af107145f64a5980db7a52177f63bb41527f360ebd2e3bef7b8917bda7b51cf284cfdb/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ! Requested runtime (ÿþPython-3.8.0) is not available for this stack (heroku-18).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-heroku-project.
remote:
To https://git.heroku.com/whatsapp-vertretungsplan-bot.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
This is the full comandline log for Python version 3.7.5:这是 Python 版本 3.7.5 的完整命令行日志:
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (40/40), 4.63 MiB | 910.00 KiB/s, done.
Total 40 (delta 11), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: /app/tmp/buildpacks/8790c95df255b386056ea169648fd4a33d1cb3fba81f73b536f26374f6af107145f64a5980db7a52177f63bb41527f360ebd2e3bef7b8917bda7b51cf284cfdb/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ! Requested runtime (ÿþPython-3.7.5) is not available for this stack (heroku-18).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-heroku-project.
remote:
To https://git.heroku.com/whatsapp-vertretungsplan-bot.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
(This is my first time working with Git and Heroku. So if the error is something obvious I'm sorry.) (这是我第一次使用 Git 和 Heroku。所以如果错误很明显,我很抱歉。)
The lines that start with "remote:" are echoed by the pre-receive hook in the remote repository.以“remote:”开头的行由远程存储库中的预接收挂钩回显。 The remote repository runs the hook to check the files before accepting your push.
远程存储库运行钩子以在接受您的推送之前检查文件。 It tries to build/parse the files and encounters an error... You can find the complete answer here.
它尝试构建/解析文件并遇到错误...您可以在此处找到完整的答案。 Heroku Deployment Issues ([remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs) .
Heroku 部署问题([remote denied] master -> master (pre-receive hook denied) error: failed to push some refs) 。
For my case I was trying to deploy a flask app but was missing a file containing the necessary dependencies.对于我的情况,我试图部署 flask 应用程序,但缺少包含必要依赖项的文件。 To correct the error I did this to generate a file with all the dependencies.
为了纠正错误,我这样做是为了生成一个包含所有依赖项的文件。 "pip freeze > requirements.txt" and damn.. My problem was solved.
“pip freeze > requirements.txt”和该死的..我的问题解决了。
The following blog gives a detailed explanation of how to deploy a Flask app on Heroku.以下博客详细说明了如何在 Heroku 上部署 Flask 应用程序。 https://medium.com/the-andela-way/deploying-a-python-flask-app-to-heroku-41250bda27d0
https://medium.com/the-andela-way/deploying-a-python-flask-app-to-heroku-41250bda27d0
How is Python written in the runtime.txt file?在runtime.txt文件中Python是怎么写的? Python or python?
Python 还是 python? This problem happened to me: I changed from Python-3.8.0 to python-3.8.0 and it worked.
这个问题发生在我身上:我从 Python-3.8.0 更改为 python-3.8.0 并且它有效。
I found out what the problem was.我发现了问题所在。
I think Heroku didn't support my encoding type, so it added some weird characters to my runtime.txt.我认为 Heroku 不支持我的编码类型,所以它在我的 runtime.txt 中添加了一些奇怪的字符。 But after a change to UTF-8 (I think, it was a long time ago) everything worked fine.
但是在更改为 UTF-8 之后(我想,那是很久以前的事了)一切正常。
In my case, I realized that had forgotten to log to Heroku via the terminal.就我而言,我意识到忘记通过终端登录到 Heroku。 Then I updated the
requirements.txt
file.然后我更新了
requirements.txt
文件。
This is what I did:这就是我所做的:
heroku login
git add.
git commit -m "requirements.txt updates"
git push heroku master.
It worked as I had expected.它按我的预期工作。
For me worked为我工作
First第一的
$ heroku config:set DISABLE_COLLECTSTATIC=1
after后
$ git push heroku main
I solved it by creating runtime.txt
file and putting the version of python that I want (python-3.7.11) into this file and then placing it the same directory as app.py
:我通过创建
runtime.txt
文件并将我想要的 python 版本(python-3.7.11)放入该文件中,然后将其放置在与app.py
相同的目录中来解决它:
app.py
Procfile
requirements.txt
runtime.txt
In most cases just disable you static file configuration with this:在大多数情况下,只需使用以下命令禁用 static 文件配置:
heroku config:set DISABLE_COLLECTSTATIC=1
and you'll be good to go.你会对 go 很好。
What worked for me was this pip freeze > requirements.txt
对我有用的是这个
pip freeze > requirements.txt
I realised that i had been forgetting to add a requirements file.我意识到我一直忘记添加需求文件。
After that, repeat the following in order.之后,按顺序重复以下操作。
git add .
git commit -am "make it better"
git push heroku master
I managed to solve the issue with the following steps:我设法通过以下步骤解决了这个问题:
pip freeze > requirements.txt
git add.
git commit -am "make it better"
Then finally I did the push again:最后我再次推动:
git push heroku master
remote: -----> Installing requirements with pip
remote: Collecting click==8.0.3
remote: Downloading click-8.0.3-py3-none-any.whl (97 kB)
remote: Collecting Flask==2.0.2
remote: Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
remote: Collecting gunicorn==20.1.0
remote: Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
remote: Collecting itsdangerous==2.0.1
remote: Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
remote: Collecting Jinja2==3.0.3
remote: Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
remote: Collecting MarkupSafe==2.0.1
remote: Downloading MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
remote: Collecting Werkzeug==2.0.2
remote: Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
remote: Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, click, gunicorn, Flask
remote: Successfully installed Flask-2.0.2 Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.0.2 click-8.0.3 gunicorn-20.1.0 itsdangerous-2.0.1
remote: -----> Skipping Django collectstatic since the env var DISABLE_COLLECTSTATIC is set.
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 62.3M
remote: -----> Launching...
remote: Released v4
remote: https://flask-heru.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/flask-heru.git
* [new branch] master -> master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.