Home > Net >  Cannot push to Heroku using Git no matter what I do
Cannot push to Heroku using Git no matter what I do

Time:04-22

Edit: I'm an idiot. I needed to use cd to actually tell Git to go to the repository. I found the solution.

I have been running around in circles trying to figure this out. I created a Discord bot and I'm trying to use Git and Heroku to host it. I've successfully gotten to the step that enables me to actually push it, but then it gives me an error.

First, my method of approach.

git add . wasn't working for me. So I specified a file directory that goes to my bot. If I do put git add . in Git Bash, I get this error message:

warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission denied
warning: could not open directory 'AppData/Local/Temp/iu-14D2N.tmp/': Permission denied
warning: could not open directory 'AppData/Local/Temp/WinSAT/': Permission denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
warning: LF will be replaced by CRLF in .bash_history.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .gitconfig.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .lesshst.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in AppData/Local/AVG/Antivirus/datascan.json.
The file will have its original line endings in your working directory
error: open("AppData/Local/Comms/UnistoreDB/USS.jtx"): Permission denied
error: unable to index file 'AppData/Local/Comms/UnistoreDB/USS.jtx'
fatal: adding files failed

I have tried running it as an administrator. The following message appears:

warning: could not open directory 'AppData/Local/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/': Function not implemented

It just. . . Freezes and it cannot do anything. I need to go into it's files and manually remove a file that caused it to break.

Anyways, git add . was not an answer. So, like I said, I specified the directory. It accepted it and then I did the following command: git commit -am "test". . . and it worked. Now, the issue is the following error message when I run git push heroku master:

Enumerating objects: 65, done.
Counting objects: 100% (65/65), done.
Delta compression using up to 4 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (65/65), 2.84 MiB | 1.02 MiB/s, done.
Total 65 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: bf75a0363f71778460026f132e502c0b02c5b388
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version bf75a0363f71778460026f132e502c0b02c5b388
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to discord-mod5.
remote:
To https://git.heroku.com/discord-mod5.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/discord-mod5.git'

(I have attempted to commit multiple times in ignorace, hence the "Warning: triggered twice" portion. Same thing still happens when I make a new commit).

Right there is where I hit a road block. Nothing was working. I deleted and re-installed Git Bash. Nothing. Ran as an administrator. Nothing. Changed buildpacks and added/removed them. Nothing. Changed requirements.txt, Procfile, and runtime.txt file contents. Nothing. renamed requirements.txt to requirement.txt. Nothing. Initialized in the root using git init and I even specified multiple directories leading up to the bot. Nothing worked.

I am back to the start. What am I doing wrong, what is happening, and what is the solution?

Contents that I'm trying to push (in this order):

  • .git(from when I initialized)
  • main.py
  • prefixes.json
  • Procifle
  • requirements.txt
  • runtime.txt

CodePudding user response:

Your problem is that your home directory is set up as a Git repository and you're trying to add everything there to your project. Windows is very strict about what programs it allows access to certain directories, like Documents, and as a result, your attempt to add everything to the repository with git add . was unsuccessful.

First, in Git Bash, type cd to go to your home directory. Then, run mv .git .git.bak. That will make your home directory no longer a Git repository, but it will preserve the directory in case you had anything important in there.

Then, go into your project directory with cd. This should definitely be a directory other than your home directory. We'll pretend it's called discord-mod5. Run git init to initialize the repository, and then run git add . and then commit.

  • Related