简体   繁体   English

git、Heroku:预收挂钩被拒绝

[英]git, Heroku: pre-receive hook declined

I am in the process of setting up a git repository and attempting to link it to Heroku.我正在设置 git 存储库并尝试将其链接到 Heroku。 When I run the command当我运行命令时

git push heroku master

I receive我收到

Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 714 bytes, done.
Total 7 (delta 1), reused 0 (delta 0)

-----> Heroku receiving push

 !     Heroku push rejected due to an unrecognized error.
 !     We've been notified, see http://support.heroku.com if the problem persists.


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

I'm not quite sure what other information would be helpful and what will just muddy the waters, so I'll just leave it at this for now.我不太确定还有哪些其他信息会有所帮助,以及哪些信息会弄得一团糟,所以我现在就暂且不谈。 Any help getting my application pushed to Heroku would be greatly appreciated.将我的应用程序推送到 Heroku 的任何帮助将不胜感激。 Thanks.谢谢。

Make sure you are pushing a repo that contains a proper supported app ( Rails, Django etc.) and you are not just pushing some random repo to test it out.确保您正在推送包含适当支持的应用程序(Rails、Django 等)的存储库,并且您不只是推送一些随机存储库来测试它。

Newbie in Heroku: Error when push my app to Heroku Heroku 中的新手:将我的应用程序推送到 Heroku 时出错

If that is not the case and you are pushing what you think is a valid app, contact Heroku support and they will fix it for you.如果不是这种情况,并且您正在推送您认为是有效的应用程序,请联系 Heroku 支持,他们会为您修复它。

Make sure that you are using either npm or yarn.lock file-确保您使用的是 npm 或 yarn.lock 文件-

Two different lockfiles found: package-lock.json and yarn.lock Both npm and yarn have created lockfiles for this application, but only one can be used to install dependencies.找到了两个不同的锁文件:package-lock.json 和 yarn.lock npm 和 yarn 都为这个应用程序创建了锁文件,但是只有一个可以用来安装依赖。

After deleting yarn.lock and pushing the code again to git, my issue resolved.删除 yarn.lock 并将代码再次推送到 git 后,我​​的问题解决了。

删除 package-lock.json 为我解决了它

First, disable collectstatic:首先,禁用 collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

Then run:然后运行:

git push heroku master

For more details and full steps, check here .有关更多详细信息和完整步骤, 请查看此处

I faced the same problem:我遇到了同样的问题:

! [remote rejected] vX.X.XX -> master (pre-receive hook declined) 
error: failed to push some refs to 'git@heroku.com:[application-name]'

I realized that my heroku application Stack is 'cedar-10' and was deprecated from 04/11/2014 and disabled from 04/11/2015 ( Cedar-14 is now Generally Available ).我意识到我的 heroku 应用程序 Stack 是“cedar-10”,并于 2014 年 4 月 11 日被弃用,并于 2015 年 4 月 11 日被禁用( Cedar-14 现在普遍可用)。

The solution was to upgrade the heroku application Stack following the guide:解决方案是按照指南升级 heroku 应用程序堆栈:

Upgrading the production app to Cedar-14 将生产应用程序升级到 Cedar-14

Another issue could be that in a production environment, you can't use sqlite3 , the default database when you make a rails app.另一个问题可能是在生产环境中,您不能使用 sqlite3 ,这是您制作 rails 应用程序时的默认数据库。

In order to fix this, just change the database your rails app uses to Postgres.为了解决这个问题,只需将您的 rails 应用程序使用的数据库更改为 Postgres。 This can easily be accomplished by editing your Gemfile这可以通过编辑您的 Gemfile轻松完成

From your Gemfile, remove:从您的 Gemfile 中删除:

gem sqlite3;

and add the following:并添加以下内容:

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

我遇到了同样的问题,但是使用 Django 应用程序,结果发现 pip 无法下载/安装 requirements.txt 文件的依赖项之一(它是 eyeD3)

If you have an error in your css this error can also show up.如果您的 css 中有错误,也会出现此错误。

In one of my media queries I put在我的一个媒体查询中,我提出了

@media screen adn (min-width: 1000px) {

Instead of the "and" which gave me this error.而不是给我这个错误的“和”。

A good indicator that this may be the case is if you get an error that contains the message如果您收到包含消息的错误,则可能是这种情况的一个很好的指标

"Tasks: TOP => assets:precompile ... Precompiling assets failed" 

That was my first clue to look in my css.这是我查看我的 CSS 的第一个线索。

A little late to the game, one of my issues was I had an outdated sshkey .游戏有点晚了,我的一个问题是我有一个过时的sshkey Just need to update that in the settings.只需要在设置中更新它。

Another thing was I was pushing Python Django CMS, and it was running python manage.py collectstatic during deploy and it was failing.另一件事是我正在推动 Python Django CMS,它在部署期间运行python manage.py collectstatic并且失败了。 So make sure you check the log heroku logs --tail .因此,请确保检查日志heroku logs --tail That gave me another hint to turn off collectstatic , it event tells you what to type to turn it off.这给了我另一个关闭collectstatic的提示,它事件告诉你输入什么来关闭它。

I had this problem (same error with Heroku):我遇到了这个问题(与 Heroku 相同的错误):

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

The mistake I made some changes to my code and removed some parameters, apparently I missed a simple comma (,) on a line.错误我对代码进行了一些更改并删除了一些参数,显然我在一行中遗漏了一个简单的逗号(,)。 This caused a build error.这导致了构建错误。 Which was not visible in the console upon pushing, only the "pre-receive hook declined" error.推送时在控制台中看不到,只有“预接收挂钩被拒绝”错误。

SOLUTION I fixed the comma issue, rebuild and pushed to Heroku and now it works.解决方案我修复了逗号问题,重建并推送到 Heroku,现在它可以工作了。

Came across this same error when deploying a node app, but resolved with these two steps and thought I'd share in case anyone else runs into the same issues.部署节点应用程序时遇到同样的错误,但通过这两个步骤解决,并认为我会分享以防其他人遇到同样的问题。

  1. Make sure you aren't committing node_modules since heroku installs dependencies from package.json on push.确保您没有提交node_modules ,因为 heroku 在推送时从 package.json 安装依赖项。 Try adding node_modules/ to your .gitignore to ensure you don't accidentally commit it尝试将node_modules/添加到您的.gitignore以确保您不会意外提交它
  2. Heroku uses Node v12 which node-sass 4.10.0 will fail to build with. Heroku 使用 Node v12,node-sass 4.10.0 将无法使用该 Node v12 构建。 Try increasing node-sass version by adding the following.尝试通过添加以下内容来增加 node-sass 版本。 This allowed it to build successfully for me:这使它能够为我成功构建:
  "devDependencies": {
    "node-sass": "^4.12.0"
  }

I decided to read the logs line by line.我决定逐行阅读日志。 Below is part of the error logs:以下是部分错误日志:

remote:        > gbt-ltd-website-frontend@0.1.0 build /tmp/build_c37edf59
remote:        > react-scripts build
remote:        
remote:        Creating an optimized production build...
remote:        Failed to compile.
remote:        
remote:        Cannot read property 'toLowerCase' of undefined
remote:        CompileError: Begins at CSS selector .Styles_hone__1Uuf2
remote:        
remote:        
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! gbt-ltd-website-frontend@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
...
remote: !       Push rejected to gbtstructurals.
remote: 
To https://git.heroku.com/gbtstructurals.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/gbtstructurals.git'

From where the error started, "npm ERR! code ELIFECYCLE" I read up and I found the actual cause of the error.从错误开始的地方开始,“npm ERR!code ELIFECYCLE”我阅读并找到了错误的实际原因。 It was a CSS rule.这是一条 CSS 规则。 I first removed the rule and it built.我首先删除了规则并建立了它。 Then I checked my declarations and found out I was contradicting myself.然后我检查了我的声明,发现我自相矛盾。

In case if this needs anyone in future even though I am a beginner and doesn't know much about Heroku, you may have requested a version in runtime.txt file which the stack doesn't support.万一这需要任何人,即使我是初学者并且对 Heroku 不太了解,您可能已经在 runtime.txt 文件中请求了堆栈不支持的版本。

python-3.8.2 to python-3.8.10

Changing from python-3.8.2 to python-3.8.10 helped me solved it.从 python-3.8.2 更改为 python-3.8.10 帮助我解决了这个问题。 You may see the supported stacks here: https://devcenter.heroku.com/articles/python-support您可能会在此处看到支持的堆栈: https ://devcenter.heroku.com/articles/python-support

I had a similar issue with a recent application after running:运行后,我最近的应用程序遇到了类似的问题:

git push heroku master

The error:错误:

remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to stormy-escarpment-13653.
remote:
To https://git.heroku.com/stormy-escarpment-13653.git
 ! [remote rejected] master -> master (pre-receive hook declined)

The problem was that I was in the wrong directory when I ran the command.问题是我在运行命令时位于错误的目录中。 I needed to be in the root of the application.我需要位于应用程序的根目录中。 So I ran a git rm --cached <app_name> , to clean up and the ran again and it worked as expected.所以我运行了一个git rm --cached <app_name>来清理并再次运行,它按预期工作。

i thought , this will not be the error occured due to any app , or code changes.我想,这不会是由于任何应用程序或代码更改而发生的错误。 i have same problem now this happen due to the following reason:我现在有同样的问题,由于以下原因而发生这种情况:

  • 1) i have code on bitbucket/git i push the code to repository (this repo is linked with the heroku app,meanse changes to this will reflects on heroku) 1)我在 bitbucket/git 上有代码我将代码推送到存储库(此存储库与 heroku 应用程序链接,意味着对此的更改将反映在 heroku 上)
  • 2)after pushing code to repo , i am trying to push code on heroku with "git push heroku master" but due to some reason i abort this command, thats why code is not pushed to heroku 2)在将代码推送到 repo 之后,我试图用“git push heroku master”在heroku上推送代码,但由于某种原因我中止了这个命令,这就是为什么代码没有推送到heroku

  • 3)then i am agian triyng to push code to heroku it says same error 3)然后我很高兴将代码推送到heroku,它说同样的错误
    as above如上

  • 4) the solution for this is "just pull yours last commited code" and push the changes to heroku ..thats it thanks 4)解决方案是“只需拉出你最后提交的代码”并将更改推送到heroku ..那就是谢谢

I had this with a sinatra application.我有一个 sinatra 应用程序。 (Heroku does support Sinatra). (Heroku 确实支持 Sinatra)。

The instructions on the heroku blog post were incomplete heroku 博客文章上的说明不完整

https://blog.heroku.com/32_deploy_merb_sinatra_or_any_rack_app_to_heroku https://blog.heroku.com/32_deploy_merb_sinatra_or_any_rack_app_to_heroku

My program ran fine locally but I got that error when trying to push to heroku.我的程序在本地运行良好,但在尝试推送到 heroku 时出现该错误。

The heroku blogpost didn't include the need to make a gemfile and do bundle install. heroku blogpost 不包括制作 gemfile 和进行捆绑安装的需要。 The program was running locally fine, but to make it work on heroku it needed a Gemfile and bundle install on it.该程序在本地运行良好,但要使其在 heroku 上运行,它需要一个 Gemfile 并在其上安装包。

this link here https://teamtreehouse.com/community/how-can-i-make-my-sinatra-app-public mentioned that I needed a Gemfile, and mentioned the contents of the Gemfile.这个链接在这里https://teamtreehouse.com/community/how-can-i-make-my-sinatra-app-public提到我需要一个 Gemfile,并提到了 Gemfile 的内容。 And then to do bundle install.然后进行捆绑安装。 Then once that is done, then follow the instructions on that heroku blog post, of making the program file, and the config.ru and the git repo and doing heroku create (which also creates the remote), then git push heroku master.然后,一旦完成,然后按照 heroku 博客文章中的说明制作程序文件、config.ru 和 git repo 并执行 heroku create(这也创建远程),然后 git push heroku master。

ie IE

Gemfile as mentioned at treehouse link树屋链接中提到的 Gemfile

# define our source to look for gems
source "http://rubygems.org/"

# declare the sinatra dependency
gem "sinatra" 

And bundle install to install that Gemfile.并捆绑安装以安装该 Gemfile。

bundle install

hello.rb (as mentioned on heroku blogpost) hello.rb(如 heroku blogpost 中所述)

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello from Sinatra on Heroku!"
end

config.ru配置.ru

require './hello'
run Sinatra::Application

git混帐

$ git init
Initialized empty Git repository in /Users/adam/hello/.git/
$ git add .
$ git commit -m "sinatra and heroku, two great tastes"
[master (root-commit)]: created 93a9e6d: "sinatra and heroku, two great tastes"
 2 files changed, 9 insertions(+), 0 deletions(-)
 create mode 100644 config.ru
 create mode 100644 hello.rb

heroku create heroku 创建

$ heroku create
Created http://severe-spring-77.heroku.com/ | git@heroku.com:severe-spring-77.git
Git remote heroku added

the push to heroku推动heroku

$ git push heroku master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 385 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
-----> Verifying repository integrity... done, looks like a Rack app.
       Compiled slug size is 0.1MB
-----> Launching....... done
       App deployed to Heroku

To git@heroku.com:severe-spring-77.git
 * [new branch]      master -> master

对我来说,这是 java app 中未使用的导入,删除了未使用的导入,一切正常。

我的问题是我在推送之前忘记捆绑安装。

In my case I had an npm script called "build" that had the as value npm run build --prefix client .就我而言,我有一个名为“build”的 npm 脚本,它的值为npm run build --prefix client

Heroku automatically executes the npm run build command and it couldn't build my React app. Heroku 自动执行npm run build命令,但它无法构建我的 React 应用程序。 Probably because Heroku didn't install react-scripts module.可能是因为 Heroku 没有安装 react-scripts 模块。

So I renamed the command to build-client and now I can push the changes to Heroku.所以我将命令重命名为build-client ,现在我可以将更改推送到 Heroku。

Checking you config vars (in heroku) may be a good idea.检查你的配置变量(在heroku中)可能是个好主意。

I had the same error message, when I created a pipeline for my app and wanted to push to the newly created staging app.当我为我的应用程序创建管道并想要推送到新创建的暂存应用程序时,我收到了同样的错误消息。 It didn't work because the config vars I had previously set were not transferred to the new staging app (obviously).它不起作用,因为我之前设置的配置变量没有转移到新的登台应用程序(显然)。 After I added the variables once more, pushing to heroku git worked flawlessly again.在我再次添加变量后,推送到 heroku git 再次完美无缺。

Sure you already found the answer, but I'm going to share what worked for me by reading the heroku doc.当然你已经找到了答案,但我将通过阅读 heroku 文档来分享对我有用的东西。

we must disable the ' collectstatic ' with我们必须禁用' collectstatic '

heroku config: set DISABLE_COLLECTSTATIC = 1

and then push main然后推

git push heroku main

The steps which work for me对我有用的步骤

1: I just remove package-lock.json and yarn.lock 2: user npm install command 3: then push the changes to the github 4: use "git push heroku main" command. 1:我只是删除 package-lock.json 和 yarn.lock 2:用户 npm install 命令 3:然后将更改推送到 github 4:使用“git push heroku main”命令。

to know more you can visit the below links enter link description here要了解更多信息,您可以访问以下链接在此处输入链接描述

My issue is that there was one file which I did not add in my previous git commit.我的问题是我之前的 git 提交中没有添加一个文件。 The problem was fixed after I added that last file, and pushed another commit.在我添加最后一个文件并推送另一个提交后,问题得到了解决。

When I checked the logs, it showed this error:当我检查日志时,它显示了这个错误:

remote: -----> Build
remote:        Running build
remote:        
remote:        > student-app-frontend@0.1.0 build
remote:        > react-scripts build
remote:        
remote:        Creating an optimized production build...
remote:        Failed to compile.
remote:        
remote:        SassError: File to import not found or unreadable: ../../designUtils/fontDesign.
remote:                on line 2 of src/components/studentCard/StudentCard.scss
remote:        >> @import '../../designUtils/fontDesign.js';
remote:        
remote:           ^
remote:        
remote:        
remote: 
remote: -----> Build failed

This shows that Heroku was not able to find the imported file 'designUtils/fontDesign.js'这表明 Heroku 无法找到导入的文件'designUtils/fontDesign.js'

This is because I used the command git commit -am 'latest changes' instead of using the commands git add.这是因为我使用了命令git commit -am 'latest changes'而不是使用命令git add. , then git status to check if everything was added properly, and then git commit -m 'latest changes' ,然后git status检查是否所有内容都已正确添加,然后git commit -m 'latest changes'

For me it solved by this command:对我来说,它通过以下命令解决:

git push heroku master --force

or或者

git push heroku your_branch_name:master --force

尝试将 Node/php 或任何引擎更新到最新版本,然后再次部署它肯定会工作。

you need to mention the language in the root directory您需要在根目录中提及语言

how I fixed with我是如何解决的

my python flask does not mention the requirments.text我的python烧瓶没有提到requirments.text

Heroku detect the Heroku 检测到

Using buildpack: heroku/python
remote: -----> Python app detected


enter image description here在此处输入图像描述

all I did was我所做的就是

heroku config:set DISABLE_COLLECTSTATIC=1 

Then然后


git push heroku master

It's work for me.这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM