【问题标题】:Git Heroku error [remote rejected] ... (pre-receive hook declined)Git Heroku 错误 [远程拒绝] ...(预接收挂钩被拒绝)
【发布时间】:2020-03-12 00:20:00
【问题描述】:

我正在尝试将我的 repo 推送到我的 heroku 堆栈,但每次出现此错误:

 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'

这是 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'

这是 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'

(这是我第一次使用 Git 和 Heroku。所以如果错误很明显,我很抱歉。)

【问题讨论】:

  • 但是我已经尝试过 Python 3.7.5 和 Python 2.7.17 并且两者都不起作用,尽管它们在 herokustack-18 上被列为支持
  • 您的意思是我对问题的新更改吗? (很抱歉,我真的不知道在这种情况下最小的可重现示例是什么)
  • 你应该仔细检查你的runtime.txtÿþPython-3.7.5 不符合 devcenter.heroku.com/articles/python-runtimes 中的要求。
  • 好吧 1. 文档指出它区分大小写;和 2. 有一些额外的字符来自 somewhere.

标签: python git heroku


【解决方案1】:

以“remote:”开头的行由远程存储库中的 pre-receive 挂钩回显。远程存储库运行钩子以在接受您的推送之前检查文件。它尝试构建/解析文件并遇到错误... 你可以在这里找到完整的答案。 Heroku Deployment Issues ([remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs).

就我而言,我试图部署一个烧瓶应用程序,但缺少一个包含必要依赖项的文件。为了纠正错误,我这样做是为了生成一个包含所有依赖项的文件。 “pip freeze > requirements.txt”,该死的!我的问题解决了。

以下博客详细说明了如何在 Heroku 上部署 Flask 应用程序。 https://medium.com/the-andela-way/deploying-a-python-flask-app-to-heroku-41250bda27d0

【讨论】:

    【解决方案2】:

    python 在 runtime.txt 文件中是如何写的?蟒蛇还是蟒蛇?这个问题发生在我身上:我从 Python-3.8.0 更改为 python-3.8.0 并且它工作。

    【讨论】:

      【解决方案3】:

      查看您的仪表板->YOUR_APP->活动->查看日志

      您可以找到确切的错误消息。

      在我的情况下,我发现了这个(查看图片),我不得不 drop 我的 package-lock.json 因为我也有纱线.lock...

      【讨论】:

        【解决方案4】:

        我发现了问题所在。

        我认为 Heroku 不支持我的编码类型,所以它在我的 runtime.txt 中添加了一些奇怪的字符。但是在更改为 UTF-8 之后(我想,那是很久以前的事了)一切正常。

        【讨论】:

          【解决方案5】:

          就我而言,我意识到忘记通过终端登录 Heroku。然后我更新了requirements.txt 文件。

          这就是我所做的:

          1. heroku login
          2. git add .
          3. git commit -m "requirements.txt updates"
          4. git push heroku master.

          效果如我所料。

          【讨论】:

            【解决方案6】:

            为我工作

            第一

            $ heroku config:set DISABLE_COLLECTSTATIC=1
            

            之后

            $ git push heroku main
            

            【讨论】:

              【解决方案7】:

              我通过创建runtime.txt文件并将我想要的python版本(python-3.7.11)放入该文件中然后将其与app.py放在同一目录中来解决它:

              app.py
              Procfile
              requirements.txt
              runtime.txt
              

              【讨论】:

                【解决方案8】:

                在大多数情况下,只需使用以下命令禁用静态文件配置:

                heroku config:set DISABLE_COLLECTSTATIC=1
                

                你会很高兴的。

                【讨论】:

                  【解决方案9】:

                  对我有用的是这个pip freeze > requirements.txt

                  我意识到我忘记添加需求文件了。

                  之后,依次重复以下操作。

                  git add .
                  git commit -am "make it better"
                  git push heroku master
                  

                  【讨论】:

                    猜你喜欢
                    • 2012-01-03
                    • 2019-10-16
                    • 2020-07-19
                    • 2012-03-21
                    • 2015-04-03
                    • 1970-01-01
                    • 2012-08-25
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多