Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to connect to cache daemon?

Tags:

git

I am able to push fine, but I am suddenly getting this "fatal" message

$ git push
fatal: unable to connect to cache daemon: Bad file descriptor
Username for 'https://github.com':
Password for 'https://[email protected]':
fatal: unable to connect to cache daemon: Bad file descriptor
...

Why do I get this message all of the sudden? and what do I do?

I am not sure this might help, but between now and before this problem occurred

  • I was working on some branch that is not master
  • I changed my user.email in git config --global in the middle
  • my computer crashed big time because I connected the wrong project connector(that is not for the computer) to it, and I believe somehow some file got corrupted
  • After that occurred, when I tried to make a new commit,I was getting the following message : fatal: Failed to resolve HEAD as a valid ref.
  • Then I fixed it by modifying HEAD in config to "ref: refs/heads/master"
  • After coding and successfully committing the changes locally, when I tried to push it to the remote server, I got the following error message

    $ git push

    fatal: unable to connect to cache daemon: Bad file descriptor Username for 'https://github.com': Password for 'https://[email protected]': fatal: unable to connect to cache daemon: Bad file descriptor fatal: loose object 8ce710b1c78658e066cd2309b12b7766d1be4920 (stored in .git/objects/8c/e710b1c78658e066cd2309b12b7766d1be4920) is corrupt fatal: The remote end hung up unexpectedly fatal: The remote end hung up unexpectedly fatal: write error: Bad file descriptor

  • So I backed up all the changes I made, deleted the repo, clone the repo from the github, and made some changes with the backup files, add, commit, and pushed the changes fine...but still that message does not go away :(

like image 702
Alby Avatar asked Oct 08 '12 09:10

Alby


4 Answers

https://stackoverflow.com/a/14160580

solved this for me:

sudo chown kev ~/.git-credential-cache/socket

replace kev with your user if you don't know your user:

whoami
like image 55
Kev Price Avatar answered Oct 19 '22 17:10

Kev Price


Beware of manipulating ~/.git-credential-cache/socket (as with chown), for it has moved since 2014, as acknowledge by Git 2.13 (Q2 2017)
Adam K Dean also mention in the comments the path ~/.cache/git/credential/, which just needed chowning back to the user.

See commit 612c49e, commit 60759ba (17 Mar 2017), and commit e7f136b (13 Mar 2017) by Devin Lehmacher (lehmacdj).
(Merged by Junio C Hamano -- gitster -- in commit 78cf8ef, 24 Mar 2017)

credential-cache: use XDG_CACHE_HOME for socket

Make git-credential-cache follow the XDG base path specification by default. This increases consistency with other applications and helps keep clutter out of users' home directories.

Check the old socket location, ~/.git-credential-cache/, and use ~/.git-credential-cache/socket if that directory exists rather than forcing users who have used git credential-cache before to migrate to the new XDG compliant location.

Otherwise use the socket $XDG_CACHE_HOME/git/credential/socket following XDG base path specification.
Use the subdirectory credential/ in case other files are cached under $XDG_CACHE_HOME/git/ in the future and to make the socket's purpose clear.


Note: With Git 2.29 (Q4 2020), a handful of places in in-tree code still relied on being able to execute the git(man) subcommands, especially built-ins, in "git-foo" form, which have been corrected.

See commit c0e190c, commit 7cff3b6, commit 675df19 (26 Aug 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 18aff08, 03 Sep 2020)

credential-cache: use child_process.args

As child_process structure has an embedded strvec args for formulating the command line, let's use it instead of using an out-of-line argv[] whose length needs to be maintained correctly.

Also, when spawning a git subcommand, omit it from the command list and instead use the .git_cmd bit in the child_process structure.

So, no more call to git-credential-cache--daemon, but rather git credential-cache--daemon.

like image 45
VonC Avatar answered Oct 19 '22 17:10

VonC


This error comes when you try to commit using "sudo".
so the password saved is for "sudo" user only,

But when you try to commit as a normal user,
This error happens, permission denied for normal user
you can get rid of this error by using above answer Kev Price

like image 28
nicolsondsouza Avatar answered Oct 19 '22 17:10

nicolsondsouza


Quick solution

Here is the single command you need to solve the issue.

sudo chown $(whoami) ~/.cache/git/credential/socket

Read the other answers if you want a deeper understanding of what causes this issue.

like image 31
WhackinMyKeyboard Avatar answered Oct 19 '22 17:10

WhackinMyKeyboard