问题
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 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. Thanks.
回答1:
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.
回答2:
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).
The solution was to upgrade the heroku application Stack following the guide:
Upgrading the production app to Cedar-14
回答3:
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
回答4:
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)
回答5:
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.
回答6:
In case someone makes the same dumb mistake I did...
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.
Hope this helps someone!
回答7:
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.
回答8:
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
回答9:
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/ | git@heroku.com: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 git@heroku.com:severe-spring-77.git
* [new branch] master -> master
回答10:
For me it was an unused import in java app , removed the unused import and everything built fine.
回答11:
I see you already got answers. Let me just share my problem and solution incase it helps anyone else that might make the same mistake I did.
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. I wanted to share this here, so if someone else makes this mistake, they can try this as well instead of waiting for Heroku to reply.
I hope this helps someone.
回答12:
This may not help everyone, but it solved my issue - My issue was I forgot to bundle install before pushing.
Hope this helps
回答13:
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.
- Make sure you aren't committing
node_modules
since heroku installs dependencies from package.json on push. Try addingnode_modules/
to your.gitignore
to ensure you don't accidentally commit it - 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"
}
回答14:
Try Updating Node/php or any engines to latest version and then deploy again it will work for sure.
来源:https://stackoverflow.com/questions/8216586/git-heroku-pre-receive-hook-declined