{"thread":{"id":"56833","subject":"credential-store get: No such file or directory","startedAt":"2021-11-03T00:27:57Z","lastAt":"2021-11-04T14:55:53Z","messageCount":9,"participants":["Steven Penny","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"440356","messageId":"CAP8dQmu6Dfo4KBsVk+6xeR6=+S8bOKk-kbc3ub7c0jAsH61-cg@mail.gmail.com","threadId":"56833","inReplyTo":null,"subject":"credential-store get: No such file or directory","fromName":"Steven Penny","fromEmail":"srpen6@gmail.com","sentAt":"2021-11-03T00:27:44Z","receivedAt":"2021-11-03T00:27:57Z","isPatch":false,"sender":{"key":"srpen6@gmail.com","avatar":null},"body":"I recently tried to use this:\n\n    git config --global credential.helper store\n\nbut whenever I run this:\n\n    git push\n\nI get this result:\n\n    fatal: cannot run git credential-store get: No such file or directory\n\nI have tried changing HOME value, as well as XDG_CONFIG_HOME, and it\ndoesn't seem to change anything. I also tried manually creating the\ncredentials file, to see if that would fix it, but error remains. I am\nusing Git 2.33. I know this worked\nin the past, but it's been some years since I tried it.\n"},{"id":"440357","messageId":"CAP8dQmvguqPXy6Rg_RkuFmf4+LPh79HM_EBM+Wi9dYn3N+vrcQ@mail.gmail.com","threadId":"56833","inReplyTo":"CAP8dQmu6Dfo4KBsVk+6xeR6=+S8bOKk-kbc3ub7c0jAsH61-cg@mail.gmail.com","subject":"Re: credential-store get: No such file or directory","fromName":"Steven Penny","fromEmail":"srpen6@gmail.com","sentAt":"2021-11-03T01:19:56Z","receivedAt":"2021-11-03T01:20:09Z","isPatch":false,"sender":{"key":"srpen6@gmail.com","avatar":null},"body":"On Tue, Nov 2, 2021 at 7:27 PM Steven Penny wrote:\n> fatal: cannot run git credential-store get: No such file or directory\n\nI came up with a workaround. I wrote my own AskPass program using Go language.\nHere it is:\n\npackage main\n\nimport (\n   \"bytes\"\n   \"fmt\"\n   \"net/url\"\n   \"os\"\n)\n\nfunc main() {\n   cache, err := os.UserCacheDir()\n   if err != nil {\n      panic(err)\n   }\n   buf, err := os.ReadFile(cache + \"/git/credentials\")\n   if err != nil {\n      panic(err)\n   }\n   buf = bytes.TrimSpace(buf)\n   addr, err := url.Parse(string(buf))\n   if err != nil {\n      panic(err)\n   }\n   if len(os.Args) != 2 {\n      return\n   }\n   prompt := os.Args[1]\n   if len(prompt) < 8 {\n      return\n   }\n   switch prompt[:8] {\n   case \"Username\":\n      fmt.Fprintln(os.Stderr, \"Username\")\n      fmt.Println(addr.User.Username())\n   case \"Password\":\n      fmt.Fprintln(os.Stderr, \"Password\")\n      pass, ok := addr.User.Password()\n      if ok {\n         fmt.Println(pass)\n      }\n   }\n}\n"},{"id":"440359","messageId":"YYHzDuoJfWknI1XM@coredump.intra.peff.net","threadId":"56833","inReplyTo":"CAP8dQmu6Dfo4KBsVk+6xeR6=+S8bOKk-kbc3ub7c0jAsH61-cg@mail.gmail.com","subject":"Re: credential-store get: No such file or directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-11-03T02:25:18Z","receivedAt":"2021-11-03T02:25:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 02, 2021 at 07:27:44PM -0500, Steven Penny wrote:\n\n> I recently tried to use this:\n> \n>     git config --global credential.helper store\n\nThat should work...\n\n> but whenever I run this:\n> \n>     git push\n> \n> I get this result:\n> \n>     fatal: cannot run git credential-store get: No such file or directory\n\nHmm. That sounds like it is treating \"git credential-store get\" as a\nsingle executable name, rather than splitting it. I'm not sure how we'd\nend up with such a bug, though.\n\nCan you show us the contents of your ~/.gitconfig file? I'm wondering if\nthere's any funny quoting (there shouldn't be from the git-config\ncommand you gave above, but maybe there's another stale entry or\nsomething?).\n\nAlso, what does:\n\n  GIT_TRACE=1 git push\n\nsay about what it's trying to execute?\n\nAnd finally, does running:\n\n  echo \"url=https://example.com\" | git credential-store get\n\nwork? I wouldn't expect it to produce any output (since you'd have\nnothing stored for that site), but it shouldn't give you the \"no such\nfile or directory\" complaint.\n\n> I have tried changing HOME value, as well as XDG_CONFIG_HOME, and it\n> doesn't seem to change anything. I also tried manually creating the\n> credentials file, to see if that would fix it, but error remains. I am\n> using Git 2.33. I know this worked\n> in the past, but it's been some years since I tried it.\n\nI think it is not complaining about finding the credential file, but\nrunning the credential-store helper in the first place. The \"cannot run\"\nmessage comes from our run-command.c code.\n\n-Peff\n"},{"id":"440360","messageId":"CAP8dQmvoxWDnD_rbCdBS9cnwS90YFjjXcCPWLmjMq=ck7vo1Ww@mail.gmail.com","threadId":"56833","inReplyTo":"YYHzDuoJfWknI1XM@coredump.intra.peff.net","subject":"Re: credential-store get: No such file or directory","fromName":"Steven Penny","fromEmail":"srpen6@gmail.com","sentAt":"2021-11-03T03:57:09Z","receivedAt":"2021-11-03T03:57:24Z","isPatch":false,"sender":{"key":"srpen6@gmail.com","avatar":null},"body":"On Tue, Nov 2, 2021 at 9:25 PM Jeff King wrote:\n> Can you show us the contents of your ~/.gitconfig file?\n\n    [color \"diff\"]\n    meta = yellow bold\n    [credential]\n    helper = store\n    [diff]\n    wsErrorHighlight = all\n    [user]\n    email = srpen6@gmail.com\n    name = Steven Penny\n\n> Also, what does:\n>\n>   GIT_TRACE=1 git push\n>\n> say about what it's trying to execute?\n\nAha:\n\n    22:53:19.785297 run-command.c:666       trace: run_command:\ngit-remote-https origin https://github.com/89z/googleplay\n    22:53:20.024042 run-command.c:666       trace: run_command: 'git\ncredential-store get'\n\n> And finally, does running:\n>\n>   echo \"url=https://example.com\" | git credential-store get\n>\n> work? I wouldn't expect it to produce any output (since you'd have\n> nothing stored for that site), but it shouldn't give you the \"no such\n> file or directory\" complaint.\n\nNo output, not error, just as you said.\n\n> I think it is not complaining about finding the credential file, but\n> running the credential-store helper in the first place. The \"cannot run\"\n> message comes from our run-command.c code.\n\nYeah, looks like you are right, based on the trace result.\n"},{"id":"440365","messageId":"YYJuK70U8Sk7xSYl@coredump.intra.peff.net","threadId":"56833","inReplyTo":"CAP8dQmvoxWDnD_rbCdBS9cnwS90YFjjXcCPWLmjMq=ck7vo1Ww@mail.gmail.com","subject":"Re: credential-store get: No such file or directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-11-03T11:10:35Z","receivedAt":"2021-11-03T11:10:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 02, 2021 at 10:57:09PM -0500, Steven Penny wrote:\n\n> > Also, what does:\n> >\n> >   GIT_TRACE=1 git push\n> >\n> > say about what it's trying to execute?\n> \n> Aha:\n> \n>     22:53:19.785297 run-command.c:666       trace: run_command:\n> git-remote-https origin https://github.com/89z/googleplay\n>     22:53:20.024042 run-command.c:666       trace: run_command: 'git\n> credential-store get'\n\nHmm, that's the right output, I think. Even though it's wrapped in\nsingle-quotes I think that's just how run_command shows it. If I do\nsomething silly like:\n\n  [credential]\n  helper = \"!'git credential-store'\"\n\nthen I get:\n\n  07:07:49.063476 run-command.c:663       trace: run_command: ''\\''git credential-store'\\'' get'\n  'git credential-store' get: 1: git credential-store: not found\n\n> > I think it is not complaining about finding the credential file, but\n> > running the credential-store helper in the first place. The \"cannot run\"\n> > message comes from our run-command.c code.\n> \n> Yeah, looks like you are right, based on the trace result.\n\nSo I'm quite confused about exactly what's failing and why. At this\npoint I'd probably try running it under strace to see what's actually\nhappening at the syscall level. I don't think you said what OS you're\non; if it's Linux, then I suspect something like:\n\n  strace -f -e execve git push\n\nmight be interesting (dropping the \"-e execve\" will give much more\noutput which might also be interesting, but it's probably pretty big).\n\n-Peff\n"},{"id":"440379","messageId":"CAP8dQmsbR7V1zX=xpk+ah-5bgkOP3vJGTMBq_25m9Vhw_fADAQ@mail.gmail.com","threadId":"56833","inReplyTo":"YYJuK70U8Sk7xSYl@coredump.intra.peff.net","subject":"Re: credential-store get: No such file or directory","fromName":"Steven Penny","fromEmail":"srpen6@gmail.com","sentAt":"2021-11-03T16:01:16Z","receivedAt":"2021-11-03T16:01:33Z","isPatch":false,"sender":{"key":"srpen6@gmail.com","avatar":null},"body":"On Wed, Nov 3, 2021 at 6:10 AM Jeff King wrote:\n> Hmm, that's the right output, I think. Even though it's wrapped in\n> single-quotes I think that's just how run_command shows it.\n\nWhy does this have no quotes:\n\n    run-command.c:666 trace: run_command: git-remote-https origin\nhttps://github.com/89z/googleplay\n\nand this have quotes:\n\n    run-command.c:666       trace: run_command: 'git credential-store get'\n\nIf youre saying that both commands ran unquoted, then I believe you. But\nhopefully you'll agree that even if nothing is wrong with the code that runs the\ncommands, that the output is confusing at best, and misleading at worst.\n\n> So I'm quite confused about exactly what's failing and why. At this point I'd\n> probably try running it under strace to see what's actually happening at the\n> syscall level. I don't think you said what OS you're on; if it's Linux,\n\nWith all due respect, I am not going to do that. I am on Windows. I used \"git\ncredential-store\" years ago, and it worked fine. Then at some point, I\nchanged to\nusing Netrc, as it worked with both Git, and also cURL. I recently discovered\nthat the Python Requests [1] package will use Netrc as well, and that even if\nyou explicitly provide an Authorization header, Requests just go ahead and\nignores that, and uses Netrc instead. This was causing failed responses, and the\nmaintainers don't seem interested in fixing it, with the advice being\n\"just don't\nuse Netrc\". So I decided to go back to \"git credential-store\", only to discover\nthat it doesn't work anymore.\n\nHopefully you won't fault me for just wanting something that works, so I am just\ngoing to use my AskPass program [2] that I wrote in response to this situation.\nIronically, \"git push\" is actually faster now than it was with Netrc, so I guess\nthat's a win. Thanks for the responses.\n\n1. https://docs.python-requests.org\n2. http://public-inbox.org/git/CAP8dQmvguqPXy6Rg_RkuFmf4+LPh79HM_EBM+Wi9dYn3N+vrcQ@mail.gmail.com\n"},{"id":"440436","messageId":"YYOrLgj3KMq6eKpp@coredump.intra.peff.net","threadId":"56833","inReplyTo":"CAP8dQmsbR7V1zX=xpk+ah-5bgkOP3vJGTMBq_25m9Vhw_fADAQ@mail.gmail.com","subject":"Re: credential-store get: No such file or directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-11-04T09:43:10Z","receivedAt":"2021-11-04T09:43:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 03, 2021 at 11:01:16AM -0500, Steven Penny wrote:\n\n> On Wed, Nov 3, 2021 at 6:10 AM Jeff King wrote:\n> > Hmm, that's the right output, I think. Even though it's wrapped in\n> > single-quotes I think that's just how run_command shows it.\n> \n> Why does this have no quotes:\n> \n>     run-command.c:666 trace: run_command: git-remote-https origin\n> https://github.com/89z/googleplay\n> \n> and this have quotes:\n> \n>     run-command.c:666       trace: run_command: 'git credential-store get'\n> \n> If youre saying that both commands ran unquoted, then I believe you. But\n> hopefully you'll agree that even if nothing is wrong with the code that runs the\n> commands, that the output is confusing at best, and misleading at worst.\n\nIt's because internally, the \"git credential-store get\" command is\nassembled as a single string passed to the shell, whereas remote-https\nis run directly via exec/spawn.\n\nI agree the output is confusing.\n\nThat may give us a clue as to what's going wrong, though. I.e., there\ncould be some issue with the shell on your system.\n\n> Hopefully you won't fault me for just wanting something that works, so I am just\n> going to use my AskPass program [2] that I wrote in response to this situation.\n> Ironically, \"git push\" is actually faster now than it was with Netrc, so I guess\n> that's a win. Thanks for the responses.\n\nNope, that's definitely your right if you don't want to spend time\ndigging further.  But as I can't reproduce here, it may mean the problem\ngoes unsolved. We do have tests for credential-store in our test suite,\nso if it were broken for everybody, I expect we'd have noticed. If it is\nspecific to your system somehow, then you working around it is as good\nas a solution. :)\n\n-Peff\n"},{"id":"440455","messageId":"CAP8dQmtLt_2+ExGUB71nJz_PWHKRrzqQVtX7d8T6FpPqgatiFQ@mail.gmail.com","threadId":"56833","inReplyTo":"YYOrLgj3KMq6eKpp@coredump.intra.peff.net","subject":"Re: credential-store get: No such file or directory","fromName":"Steven Penny","fromEmail":"srpen6@gmail.com","sentAt":"2021-11-04T14:12:39Z","receivedAt":"2021-11-04T14:12:50Z","isPatch":false,"sender":{"key":"srpen6@gmail.com","avatar":null},"body":"On Thu, Nov 4, 2021 at 4:43 AM Jeff King wrote:\n> It's because internally, the \"git credential-store get\" command is\n> assembled as a single string passed to the shell, whereas remote-https\n> is run directly via exec/spawn.\n\nActually, I bet that is whats causing the problem. I am using MSYS2 Git [1],\nwhich is not a native Windows build of Git, but one that relies on the MSYS2 DLL\nfor path translations and such. I have actually built a Windows native Git, but\nits a pain, so its easier just to use the package. Anyway, the \"non native\"\nWindows version, probably considers Bash the shell, so any commands being passed\nto a shell probably will be looking for Bash. I dont have Bash on my system,\nbecause for the most part I dont want or need it. If I need a shell, I just use\nPowerShell.\n\nWould it be possible for Git to just run \"credential-store\" directly, like other\ncommands? I assume stuff like \"~/.git-credentials\" would be a problem, but\ncouldnt you just do something like this instead (pseudocode):\n\n    var cred string = os.Getenv(\"HOME\") + \"/.git-credentials\"\n\n1. https://packages.msys2.org/package/git\n"},{"id":"440458","messageId":"YYP0dnBgfY16fSP7@coredump.intra.peff.net","threadId":"56833","inReplyTo":"CAP8dQmtLt_2+ExGUB71nJz_PWHKRrzqQVtX7d8T6FpPqgatiFQ@mail.gmail.com","subject":"Re: credential-store get: No such file or directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-11-04T14:55:50Z","receivedAt":"2021-11-04T14:55:53Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 04, 2021 at 09:12:39AM -0500, Steven Penny wrote:\n\n> On Thu, Nov 4, 2021 at 4:43 AM Jeff King wrote:\n> > It's because internally, the \"git credential-store get\" command is\n> > assembled as a single string passed to the shell, whereas remote-https\n> > is run directly via exec/spawn.\n> \n> Actually, I bet that is whats causing the problem. I am using MSYS2 Git [1],\n> which is not a native Windows build of Git, but one that relies on the MSYS2 DLL\n> for path translations and such. I have actually built a Windows native Git, but\n> its a pain, so its easier just to use the package. Anyway, the \"non native\"\n> Windows version, probably considers Bash the shell, so any commands being passed\n> to a shell probably will be looking for Bash. I dont have Bash on my system,\n> because for the most part I dont want or need it. If I need a shell, I just use\n> PowerShell.\n\nOK, that would explain it, I think.\n\n> Would it be possible for Git to just run \"credential-store\" directly, like other\n> commands? I assume stuff like \"~/.git-credentials\" would be a problem, but\n> couldnt you just do something like this instead (pseudocode):\n> \n>     var cred string = os.Getenv(\"HOME\") + \"/.git-credentials\"\n\nPossible yes, easy no.\n\nThe \"~\" part is trivial; that's expanded inside the C program anyway.\nThe harder thing is that helper strings can be arbitrary shell commands\n(if you start them with \"!\"), so we decide at parse time whether to\nstick the \"git credential-\" in front and then always treat it as a shell\ncommand, rather than carrying through the knowledge that it doesn't need\na shell. So switching that would ripple through the whole call stack and\nthe data structures.\n\nDefinitely not impossible, and not even _hard_, but it's not like a\none-liner change.\n\n-Peff\n"}]}