git,Heroku:预接收挂钩被拒绝

发布于 2024-12-17 02:06:35 字数 969 浏览 6 评论 0原文

我正在设置 git 存储库并尝试将其链接到 Heroku。当我运行命令时,

git push heroku master

我收到

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 [email protected]:morning-stream-3712.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:morning-stream-3712.git'

How can I get my application Push to Heroku?

I am in the process of setting up a git repository and attempting to link it to 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 [email protected]:morning-stream-3712.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:morning-stream-3712.git'

How can I get my application pushed to Heroku?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(26

无风消散 2024-12-24 02:06:35

确保您推送的存储库包含适当支持的应用程序(Rails、Django 等),并且您不仅仅是推送一些随机存储库来测试它。

Heroku 新手:推送我的时出错应用程序到 Heroku

如果情况并非如此,并且您正在推送您认为有效的应用程序,请联系 Heroku 支持人员,他们会为您修复它。

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.

Newbie in Heroku: Error when push my app to 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.

怪我太投入 2024-12-24 02:06:35

确保您使用的是npm或yarn.lock文件-

找到两个不同的锁文件:package-lock.json和yarn.lock
npm 和yarn 都为此应用程序创建了锁定文件,
但只能使用一个来安装依赖项。

删除yarn.lock并再次将代码推送到git后,我的问题解决了。

Make sure that you are using either npm or yarn.lock file-

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.

After deleting yarn.lock and pushing the code again to git, my issue resolved.

撩人痒 2024-12-24 02:06:35

删除 package-lock.json 为我解决了这个问题

Deleting package-lock.json solved it for me

神经大条 2024-12-24 02:06:35

首先,禁用collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

然后运行:

git push heroku master

有关更多详细信息和完整步骤,检查这里

First, disable collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

Then run:

git push heroku master

For more details and full steps, check here.

浅唱ヾ落雨殇 2024-12-24 02:06:35

我遇到了同样的问题:

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

我意识到我的heroku应用程序堆栈是“cedar-10”,并且从2014年4月11日起被弃用,并从2015年4月11日起被禁用(Cedar-14 现已全面上市)。

解决方案是按照指南升级heroku应用程序堆栈:

将生产应用升级到 Cedar-14

I faced the same problem:

! [remote rejected] vX.X.XX -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:[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).

The solution was to upgrade the heroku application Stack following the guide:

Upgrading the production app to Cedar-14

裂开嘴轻声笑有多痛 2024-12-24 02:06:35

另一个问题可能是,在生产环境中,您无法使用 sqlite3(制作 Rails 应用程序时的默认数据库)。

为了解决这个问题,只需将 Rails 应用程序使用的数据库更改为 Postgres 即可。这可以通过编辑您的 Gemfile 轻松完成

,从您的 Gemfile 中删除:

gem sqlite3;

并添加以下内容:

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

group :production do
  gem 'pg'
end

Another issue could be that in a production environment, you can't use sqlite3, the default database when you make a rails app.

In order to fix this, just change the database your rails app uses to Postgres. This can easily be accomplished by editing your Gemfile

From your Gemfile, remove:

gem sqlite3;

and add the following:

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

group :production do
  gem 'pg'
end
听风念你 2024-12-24 02:06:35

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

I had the same problem but with a Django app, it turned out that pip wasn't able to download/install one of the dependencies of the requirements.txt file (it was eyeD3)

苦行僧 2024-12-24 02:06:35

游戏有点晚了,我的问题之一是我有一个过时的 sshkey。只需要在设置中更新即可。

另一件事是我正在推动 Python Django CMS,它在部署过程中运行 python manage.pycollectstatic 并且失败了。因此,请务必检查日志 heroku logs --tail。这给了我另一个关闭 collectstatic 的提示,它的事件告诉你要输入什么来关闭它。

A little late to the game, one of my issues was I had an outdated 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. So make sure you check the log heroku logs --tail. That gave me another hint to turn off collectstatic, it event tells you what to type to turn it off.

清浅ˋ旧时光 2024-12-24 02:06:35

在部署节点应用程序时遇到了同样的错误,但通过这两个步骤解决了,并认为我会分享以防其他人遇到相同的问题。

  1. 确保您没有提交 node_modules 因为 heroku 在推送时从 package.json 安装依赖项。尝试将 node_modules/ 添加到 .gitignore 以确保您不会意外提交它
  2. Heroku 使用 Node v12,node-sass 4.10.0 将无法使用 Node v12 进行构建。尝试通过添加以下内容来增加 node-sass 版本。这使它能够为我成功构建:
  "devDependencies": {
    "node-sass": "^4.12.0"
  }

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. Try adding node_modules/ to your .gitignore to ensure you don't accidentally commit it
  2. Heroku uses Node v12 which node-sass 4.10.0 will fail to build with. Try increasing node-sass version by adding the following. This allowed it to build successfully for me:
  "devDependencies": {
    "node-sass": "^4.12.0"
  }
对你再特殊 2024-12-24 02:06:35

如果将来需要任何人,即使我是初学者并且对 Heroku 不太了解,您也可能在 runtime.txt 文件中请求了堆栈不支持的版本。

python-3.8.2 到 python-3.8.10

从 python-3.8.2 更改为 python-3.8.10 帮助我解决了这个问题。您可能会在此处看到支持的堆栈: https://devcenter.heroku.com/articles/python-支持

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.

python-3.8.2 to python-3.8.10

Changing from python-3.8.2 to python-3.8.10 helped me solved it. You may see the supported stacks here: https://devcenter.heroku.com/articles/python-support

渔村楼浪 2024-12-24 02:06:35

我遇到了这个问题(与 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'

错误
我对代码做了一些更改并删除了一些参数,显然我错过了一行上的一个简单的逗号 (,)。这导致了构建错误。推送后控制台中看不到这一点,只有“预接收挂钩拒绝”错误。

解决方案
我修复了逗号问题,重建并推送到 Heroku,现在它可以工作了。

I had this problem (same error with 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.

好菇凉咱不稀罕他 2024-12-24 02:06:35

如果你的 CSS 中有错误,这个错误也会出现。

在我的一个媒体查询中,我放置了

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

“和”,而不是给我这个错误。

一个很好的迹象表明可能是这种情况,如果您收到包含以下消息的错误

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

,这是我在 css 中查找的第一个线索。

If you have an error in your css this error can also show up.

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.

九局 2024-12-24 02:06:35

我决定逐行阅读日志。
以下是错误日志的一部分:

remote:        > [email protected] 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! [email protected] 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'

从错误开始的地方,“npm ERR!code ELIFECYCLE”我读了一下,发现了错误的实际原因。这是 CSS 规则。我首先删除了规则,然后它就建立了。然后我检查了我的声明,发现我自相矛盾。

I decided to read the logs line by line.
Below is part of the error logs:

remote:        > [email protected] 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! [email protected] 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. It was a CSS rule. I first removed the rule and it built. Then I checked my declarations and found out I was contradicting myself.

养猫人 2024-12-24 02:06:35

我的问题是,有一个文件我没有在之前的 git 提交中添加。在我添加最后一个文件并推送另一个提交后,问题得到解决。

当我检查日志时,它显示了这个错误:

remote: -----> Build
remote:        Running build
remote:        
remote:        > [email protected] 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 indicates the Heroku was not able to find the imported file 'designUtils/fontDesign.js'

This is because I using the command git commit - am '最新更改' 而不是使用命令 git add.,然后使用 git status 检查所有内容是否已正确添加,然后使用 git commit -m '最新更改'

My issue is that there was one file which I did not add in my previous git commit. 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:        > [email protected] 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'

This is because I used the command git commit -am 'latest changes' instead of using the commands git add., then git status to check if everything was added properly, and then git commit -m 'latest changes'

逆蝶 2024-12-24 02:06:35

我认为,这不会是由于任何应用程序或代码更改而发生的错误。
我现在遇到同样的问题,这是由于以下原因发生的:

  • 1)我在 bitbucket/git 上有代码,我将代码推送到存储库(这
    repo 与 heroku 应用程序链接,意味着对此的更改将
    反映在heroku上)
  • 2)将代码推送到repo后,我尝试在heroku上推送代码
    使用“git push heroku master”,但由于某种原因我中止了这个
    命令,这就是为什么代码没有推送到heroku

  • 3)然后我再次尝试将代码推送到heroku,它说同样的错误
    如上所述

  • 4)解决方案是“只需拉出你最后提交的代码”
    并将更改推送到 heroku ..就是这样,谢谢

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)
  • 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

  • 3)then i am agian triyng to push code to heroku it says same error
    as above

  • 4) the solution for this is "just pull yours last commited code"
    and push the changes to heroku ..thats it thanks
彩扇题诗 2024-12-24 02:06:35

我有一个 sinatra 应用程序。 (Heroku 确实支持 Sinatra)。

Heroku 博客文章中的说明不完整

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

我的程序在本地运行良好,但在尝试推送时出现错误赫罗库。

heroku 博客文章没有包含制作 gemfile 和进行捆绑安装的需要。该程序在本地运行良好,但为了使其在 Heroku 上运行,需要在其上安装 Gemfile 和捆绑包。

此链接位于 https://teamtreehouse.com/community /how-can-i-make-my-sinatra-app-public 提到我需要一个 Gemfile,并提到了 Gemfile 的内容。然后进行捆绑安装。完成后,然后按照 heroku 博客文章上的说明进行操作,制作程序文件、config.ru 和 git 存储库并执行 heroku create (这也会创建远程),然后 git Push heroku master。

树屋链接中提到的 Gemfile

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

# declare the sinatra dependency
gem "sinatra" 

并捆绑安装以安装该 Gemfile。

bundle install

hello.rb (如heroku博客文章中提到的)

require 'rubygems'
require 'sinatra'

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

config.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 创建

$ heroku create
Created http://severe-spring-77.heroku.com/ | [email protected]:severe-spring-77.git
Git remote heroku added

到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 [email protected]:severe-spring-77.git
 * [new branch]      master -> master

I had this with a sinatra application. (Heroku does support Sinatra).

The instructions on the heroku blog post were incomplete

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.

The heroku blogpost didn't include the need to make a gemfile and do bundle install. The program was running locally fine, but to make it work on heroku it needed a Gemfile and bundle install on it.

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. 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.

i.e.

Gemfile as mentioned at treehouse link

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

# declare the sinatra dependency
gem "sinatra" 

And bundle install to install that Gemfile.

bundle install

hello.rb (as mentioned on heroku blogpost)

require 'rubygems'
require 'sinatra'

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

config.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 create
Created http://severe-spring-77.heroku.com/ | [email protected]:severe-spring-77.git
Git remote heroku added

the push to 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 [email protected]:severe-spring-77.git
 * [new branch]      master -> master
救星 2024-12-24 02:06:35

对我来说,这是 java app 中未使用的导入,删除了未使用的导入,一切都构建得很好。

For me it was an unused import in java app , removed the unused import and everything built fine.

随心而道 2024-12-24 02:06:35

就我而言,我有一个名为“build”的 npm 脚本,其值为 npm run build --prefix client

Heroku 自动执行 npm run build 命令,但无法构建我的 React 应用程序。可能是因为Heroku没有安装react-scripts模块。

因此,我将该命令重命名为 build-client,现在我可以将更改推送到 Heroku。

In my case I had an npm script called "build" that had the as value npm run build --prefix client.

Heroku automatically executes the npm run build command and it couldn't build my React app. Probably because Heroku didn't install react-scripts module.

So I renamed the command to build-client and now I can push the changes to Heroku.

燕归巢 2024-12-24 02:06:35

检查配置变量(在heroku中)可能是个好主意。

当我为我的应用程序创建管道并想要推送到新创建的临时应用程序时,我遇到了相同的错误消息。它不起作用,因为我之前设置的配置变量没有传输到新的登台应用程序(显然)。在我再次添加变量后,推送到 heroku git 再次完美地工作。

Checking you config vars (in heroku) may be a good idea.

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.

雪落纷纷 2024-12-24 02:06:35

运行后我对最近的应用程序遇到了类似的问题:

git push heroku master

错误:

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)

问题是运行命令时我位于错误的目录中。我需要位于应用程序的根目录中。
所以我运行了 git rm --cached来清理并再次运行,它按预期工作。

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.

残疾 2024-12-24 02:06:35

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

My issue was I forgot to bundle install before pushing.

水波映月 2024-12-24 02:06:35

对我有用的步骤

1:我只是删除package-lock.json和yarn.lock
2:用户npm安装命令
3:然后将修改推送到github
4:使用“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.

to know more you can visit the below links enter link description here

幽梦紫曦~ 2024-12-24 02:06:35

对我来说,它通过这个命令解决:

git push heroku master --force

git push heroku your_branch_name:master --force

For me it solved by this command:

git push heroku master --force

or

git push heroku your_branch_name:master --force
ˇ宁静的妩媚 2024-12-24 02:06:35

如果您从 github 复制了项目并且有多个锁定文件,则可能会发生这种情况

最好的方法是删除锁定文件

yarn.lock and package-lock.json

,然后推送更改

git add . 
git commit -m "deleted locks"
git push origin master
heroku push master

This can happen if you have copied project from github and have multiple lock files

Best way is to remove lock files

yarn.lock and package-lock.json

then push the changes

git add . 
git commit -m "deleted locks"
git push origin master
heroku push master
╰沐子 2024-12-24 02:06:35

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

Try Updating Node/php or any engines to latest version and then deploy again it will work for sure.

风尘浪孓 2024-12-24 02:06:35

你需要提及根目录中的语言

我如何使用Python Flask修复

没有提及requirments.text

Heroku检测

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


在此输入图片描述

you need to mention the language in the root directory

how I fixed with

my python flask does not mention the requirments.text

Heroku detect the

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


enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文