簡體   English   中英

git、Heroku:預收掛鈎被拒絕

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

我正在設置 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 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'

我不太確定還有哪些其他信息會有所幫助,以及哪些信息會弄得一團糟,所以我現在就暫且不談。 將我的應用程序推送到 Heroku 的任何幫助將不勝感激。 謝謝。

確保您正在推送包含適當支持的應用程序(Rails、Django 等)的存儲庫,並且您不只是推送一些隨機存儲庫來測試它。

Heroku 中的新手:將我的應用程序推送到 Heroku 時出錯

如果不是這種情況,並且您正在推送您認為是有效的應用程序,請聯系 Heroku 支持,他們會為您修復它。

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

找到了兩個不同的鎖文件:package-lock.json 和 yarn.lock npm 和 yarn 都為這個應用程序創建了鎖文件,但是只有一個可以用來安裝依賴。

刪除 yarn.lock 並將代碼再次推送到 git 后,我​​的問題解決了。

刪除 package-lock.json 為我解決了它

首先,禁用 collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

然后運行:

git push heroku master

有關更多詳細信息和完整步驟, 請查看此處

我遇到了同樣的問題:

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

我意識到我的 heroku 應用程序 Stack 是“cedar-10”,並於 2014 年 4 月 11 日被棄用,並於 2015 年 4 月 11 日被禁用( Cedar-14 現在普遍可用)。

解決方案是按照指南升級 heroku 應用程序堆棧:

將生產應用程序升級到 Cedar-14

另一個問題可能是在生產環境中,您不能使用 sqlite3 ,這是您制作 rails 應用程序時的默認數據庫。

為了解決這個問題,只需將您的 rails 應用程序使用的數據庫更改為 Postgres。 這可以通過編輯您的 Gemfile輕松完成

從您的 Gemfile 中刪除:

gem sqlite3;

並添加以下內容:

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

group :production do
  gem 'pg'
end

我遇到了同樣的問題,但是使用 Django 應用程序,結果發現 pip 無法下載/安裝 requirements.txt 文件的依賴項之一(它是 eyeD3)

如果您的 css 中有錯誤,也會出現此錯誤。

在我的一個媒體查詢中,我提出了

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

而不是給我這個錯誤的“和”。

如果您收到包含消息的錯誤,則可能是這種情況的一個很好的指標

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

這是我查看我的 CSS 的第一個線索。

游戲有點晚了,我的一個問題是我有一個過時的sshkey 只需要在設置中更新它。

另一件事是我正在推動 Python Django CMS,它在部署期間運行python manage.py collectstatic並且失敗了。 因此,請確保檢查日志heroku logs --tail 這給了我另一個關閉collectstatic的提示,它事件告訴你輸入什么來關閉它。

我遇到了這個問題(與 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,現在它可以工作了。

部署節點應用程序時遇到同樣的錯誤,但通過這兩個步驟解決,並認為我會分享以防其他人遇到同樣的問題。

  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"
  }

我決定逐行閱讀日志。 以下是部分錯誤日志:

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'

從錯誤開始的地方開始,“npm ERR!code ELIFECYCLE”我閱讀並找到了錯誤的實際原因。 這是一條 CSS 規則。 我首先刪除了規則並建立了它。 然后我檢查了我的聲明,發現我自相矛盾。

萬一這需要任何人,即使我是初學者並且對 Heroku 不太了解,您可能已經在 runtime.txt 文件中請求了堆棧不支持的版本。

python-3.8.2 to python-3.8.10

從 python-3.8.2 更改為 python-3.8.10 幫助我解決了這個問題。 您可能會在此處看到支持的堆棧: https ://devcenter.heroku.com/articles/python-support

運行后,我最近的應用程序遇到了類似的問題:

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 <app_name>來清理並再次運行,它按預期工作。

我想,這不會是由於任何應用程序或代碼更改而發生的錯誤。 我現在有同樣的問題,由於以下原因而發生這種情況:

  • 1)我在 bitbucket/git 上有代碼我將代碼推送到存儲庫(此存儲庫與 heroku 應用程序鏈接,意味着對此的更改將反映在 heroku 上)
  • 2)在將代碼推送到 repo 之后,我試圖用“git push heroku master”在heroku上推送代碼,但由於某種原因我中止了這個命令,這就是為什么代碼沒有推送到heroku

  • 3)然后我很高興將代碼推送到heroku,它說同樣的錯誤
    如上

  • 4)解決方案是“只需拉出你最后提交的代碼”並將更改推送到heroku ..那就是謝謝

我有一個 sinatra 應用程序。 (Heroku 確實支持 Sinatra)。

heroku 博客文章上的說明不完整

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

我的程序在本地運行良好,但在嘗試推送到 heroku 時出現該錯誤。

heroku blogpost 不包括制作 gemfile 和進行捆綁安裝的需要。 該程序在本地運行良好,但要使其在 heroku 上運行,它需要一個 Gemfile 並在其上安裝包。

這個鏈接在這里https://teamtreehouse.com/community/how-can-i-make-my-sinatra-app-public提到我需要一個 Gemfile,並提到了 Gemfile 的內容。 然后進行捆綁安裝。 然后,一旦完成,然后按照 heroku 博客文章中的說明制作程序文件、config.ru 和 git repo 並執行 heroku create(這也創建遠程),然后 git push heroku master。

IE

樹屋鏈接中提到的 Gemfile

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

# declare the sinatra dependency
gem "sinatra" 

並捆綁安裝以安裝該 Gemfile。

bundle install

hello.rb(如 heroku blogpost 中所述)

require 'rubygems'
require 'sinatra'

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

配置.ru

require './hello'
run Sinatra::Application

混帳

$ 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/ | git@heroku.com: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 git@heroku.com:severe-spring-77.git
 * [new branch]      master -> master

對我來說,這是 java app 中未使用的導入,刪除了未使用的導入,一切正常。

我的問題是我在推送之前忘記捆綁安裝。

就我而言,我有一個名為“build”的 npm 腳本,它的值為npm run build --prefix client

Heroku 自動執行npm run build命令,但它無法構建我的 React 應用程序。 可能是因為 Heroku 沒有安裝 react-scripts 模塊。

所以我將命令重命名為build-client ,現在我可以將更改推送到 Heroku。

檢查你的配置變量(在heroku中)可能是個好主意。

當我為我的應用程序創建管道並想要推送到新創建的暫存應用程序時,我收到了同樣的錯誤消息。 它不起作用,因為我之前設置的配置變量沒有轉移到新的登台應用程序(顯然)。 在我再次添加變量后,推送到 heroku git 再次完美無缺。

當然你已經找到了答案,但我將通過閱讀 heroku 文檔來分享對我有用的東西。

我們必須禁用' collectstatic '

heroku config: set DISABLE_COLLECTSTATIC = 1

然后推

git push heroku main

對我有用的步驟

1:我只是刪除 package-lock.json 和 yarn.lock 2:用戶 npm install 命令 3:然后將更改推送到 github 4:使用“git push heroku main”命令。

要了解更多信息,您可以訪問以下鏈接在此處輸入鏈接描述

我的問題是我之前的 git 提交中沒有添加一個文件。 在我添加最后一個文件並推送另一個提交后,問題得到了解決。

當我檢查日志時,它顯示了這個錯誤:

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

這表明 Heroku 無法找到導入的文件'designUtils/fontDesign.js'

這是因為我使用了命令git commit -am 'latest changes'而不是使用命令git add. ,然后git status檢查是否所有內容都已正確添加,然后git commit -m 'latest changes'

對我來說,它通過以下命令解決:

git push heroku master --force

或者

git push heroku your_branch_name:master --force

嘗試將 Node/php 或任何引擎更新到最新版本,然后再次部署它肯定會工作。

您需要在根目錄中提及語言

我是如何解決的

我的python燒瓶沒有提到requirments.text

Heroku 檢測到

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


在此處輸入圖像描述

我所做的就是

heroku config:set DISABLE_COLLECTSTATIC=1 

然后


git push heroku master

這對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM