threads / discuss / 56833

credential-store get: No such file or directory

Subject: credential-store get: No such file or directory

## tl;dr

9 messages between Nov 3, 2021 and Nov 4, 2021.

replies: 8people: 2as markdown or json

Steven Penny· Nov 3, 2021, 00:27 UTC · lore
I recently tried to use this:
    git config --global credential.helper store
but whenever I run this:
    git push
I get this result:
    fatal: cannot run git credential-store get: No such file or directory

I have tried changing HOME value, as well as XDG_CONFIG_HOME, and it doesn't seem to change anything. I also tried manually creating the credentials file, to see if that would fix it, but error remains. I am using Git 2.33. I know this worked in the past, but it's been some years since I tried it.

Steven Penny· Nov 3, 2021, 01:19 UTC · re: Steven Penny · lore

Re: credential-store get: No such file or directory

On Tue, Nov 2, 2021 at 7:27 PM Steven Penny wrote:
> fatal: cannot run git credential-store get: No such file or directory

I came up with a workaround. I wrote my own AskPass program using Go language. Here it is:

package main
import (
   "bytes"
   "fmt"
   "net/url"
   "os"
)
func main() {
   cache, err := os.UserCacheDir()
   if err != nil {
      panic(err)
   }
   buf, err := os.ReadFile(cache + "/git/credentials")
   if err != nil {
      panic(err)
   }
   buf = bytes.TrimSpace(buf)
   addr, err := url.Parse(string(buf))
   if err != nil {
      panic(err)
   }
   if len(os.Args) != 2 {
      return
   }
   prompt := os.Args[1]
   if len(prompt) < 8 {
      return
   }
   switch prompt[:8] {
   case "Username":
      fmt.Fprintln(os.Stderr, "Username")
      fmt.Println(addr.User.Username())
   case "Password":
      fmt.Fprintln(os.Stderr, "Password")
      pass, ok := addr.User.Password()
      if ok {
         fmt.Println(pass)
      }
   }
}
Jeff King· Nov 3, 2021, 02:25 UTC · re: Steven Penny · lore

Re: credential-store get: No such file or directory

On Tue, Nov 02, 2021 at 07:27:44PM -0500, Steven Penny wrote:
> I recently tried to use this:
> 
>     git config --global credential.helper store
That should work...
Show 7 quoted lines
> but whenever I run this:
> 
>     git push
> 
> I get this result:
> 
>     fatal: cannot run git credential-store get: No such file or directory

Hmm. That sounds like it is treating "git credential-store get" as a single executable name, rather than splitting it. I'm not sure how we'd end up with such a bug, though.

Can you show us the contents of your ~/.gitconfig file? I'm wondering if there's any funny quoting (there shouldn't be from the git-config command you gave above, but maybe there's another stale entry or something?).

Also, what does:
  GIT_TRACE=1 git push
say about what it's trying to execute?
And finally, does running:
  echo "url=https://example.com" | git credential-store get

work? I wouldn't expect it to produce any output (since you'd have nothing stored for that site), but it shouldn't give you the "no such file or directory" complaint.

Show 5 quoted lines
> I have tried changing HOME value, as well as XDG_CONFIG_HOME, and it
> doesn't seem to change anything. I also tried manually creating the
> credentials file, to see if that would fix it, but error remains. I am
> using Git 2.33. I know this worked
> in the past, but it's been some years since I tried it.

I think it is not complaining about finding the credential file, but running the credential-store helper in the first place. The "cannot run" message comes from our run-command.c code.

-Peff
Steven Penny· Nov 3, 2021, 03:57 UTC · re: Jeff King · lore

Re: credential-store get: No such file or directory

On Tue, Nov 2, 2021 at 9:25 PM Jeff King wrote:
> Can you show us the contents of your ~/.gitconfig file?
    [color "diff"]
    meta = yellow bold
    [credential]
    helper = store
    [diff]
    wsErrorHighlight = all
    [user]
    email = srpen6@gmail.com
    name = Steven Penny
Show 5 quoted lines
> Also, what does:
>
>   GIT_TRACE=1 git push
>
> say about what it's trying to execute?
Aha:
    22:53:19.785297 run-command.c:666       trace: run_command:
git-remote-https origin https://github.com/89z/googleplay
    22:53:20.024042 run-command.c:666       trace: run_command: 'git
credential-store get'
Show 7 quoted lines
> And finally, does running:
>
>   echo "url=https://example.com" | git credential-store get
>
> work? I wouldn't expect it to produce any output (since you'd have
> nothing stored for that site), but it shouldn't give you the "no such
> file or directory" complaint.
No output, not error, just as you said.
> I think it is not complaining about finding the credential file, but
> running the credential-store helper in the first place. The "cannot run"
> message comes from our run-command.c code.
Yeah, looks like you are right, based on the trace result.
Jeff King· Nov 3, 2021, 11:10 UTC · re: Steven Penny · lore

Re: credential-store get: No such file or directory

On Tue, Nov 02, 2021 at 10:57:09PM -0500, Steven Penny wrote:
Show 12 quoted lines
> > Also, what does:
> >
> >   GIT_TRACE=1 git push
> >
> > say about what it's trying to execute?
> 
> Aha:
> 
>     22:53:19.785297 run-command.c:666       trace: run_command:
> git-remote-https origin https://github.com/89z/googleplay
>     22:53:20.024042 run-command.c:666       trace: run_command: 'git
> credential-store get'

Hmm, that's the right output, I think. Even though it's wrapped in single-quotes I think that's just how run_command shows it. If I do something silly like:

  [credential]
  helper = "!'git credential-store'"
then I get:
  07:07:49.063476 run-command.c:663       trace: run_command: ''\''git credential-store'\'' get'
  'git credential-store' get: 1: git credential-store: not found
Show 5 quoted lines
> > I think it is not complaining about finding the credential file, but
> > running the credential-store helper in the first place. The "cannot run"
> > message comes from our run-command.c code.
> 
> Yeah, looks like you are right, based on the trace result.

So I'm quite confused about exactly what's failing and why. At this point I'd probably try running it under strace to see what's actually happening at the syscall level. I don't think you said what OS you're on; if it's Linux, then I suspect something like:

  strace -f -e execve git push

might be interesting (dropping the "-e execve" will give much more output which might also be interesting, but it's probably pretty big).

-Peff
Steven Penny· Nov 3, 2021, 16:01 UTC · re: Jeff King · lore

Re: credential-store get: No such file or directory

On Wed, Nov 3, 2021 at 6:10 AM Jeff King wrote:
> Hmm, that's the right output, I think. Even though it's wrapped in
> single-quotes I think that's just how run_command shows it.
Why does this have no quotes:
    run-command.c:666 trace: run_command: git-remote-https origin
https://github.com/89z/googleplay
and this have quotes:
    run-command.c:666       trace: run_command: 'git credential-store get'

If youre saying that both commands ran unquoted, then I believe you. But hopefully you'll agree that even if nothing is wrong with the code that runs the commands, that the output is confusing at best, and misleading at worst.

> So I'm quite confused about exactly what's failing and why. At this point I'd
> probably try running it under strace to see what's actually happening at the
> syscall level. I don't think you said what OS you're on; if it's Linux,

With all due respect, I am not going to do that. I am on Windows. I used "git credential-store" years ago, and it worked fine. Then at some point, I changed to using Netrc, as it worked with both Git, and also cURL. I recently discovered that the Python Requests [1] package will use Netrc as well, and that even if you explicitly provide an Authorization header, Requests just go ahead and ignores that, and uses Netrc instead. This was causing failed responses, and the maintainers don't seem interested in fixing it, with the advice being "just don't use Netrc". So I decided to go back to "git credential-store", only to discover that it doesn't work anymore.

Hopefully you won't fault me for just wanting something that works, so I am just going to use my AskPass program [2] that I wrote in response to this situation. Ironically, "git push" is actually faster now than it was with Netrc, so I guess that's a win. Thanks for the responses.

1. https://docs.python-requests.org
2. http://public-inbox.org/git/CAP8dQmvguqPXy6Rg_RkuFmf4+LPh79HM_EBM+Wi9dYn3N+vrcQ@mail.gmail.com
Jeff King· Nov 4, 2021, 09:43 UTC · re: Steven Penny · lore

Re: credential-store get: No such file or directory

On Wed, Nov 03, 2021 at 11:01:16AM -0500, Steven Penny wrote:
Show 16 quoted lines
> On Wed, Nov 3, 2021 at 6:10 AM Jeff King wrote:
> > Hmm, that's the right output, I think. Even though it's wrapped in
> > single-quotes I think that's just how run_command shows it.
> 
> Why does this have no quotes:
> 
>     run-command.c:666 trace: run_command: git-remote-https origin
> https://github.com/89z/googleplay
> 
> and this have quotes:
> 
>     run-command.c:666       trace: run_command: 'git credential-store get'
> 
> If youre saying that both commands ran unquoted, then I believe you. But
> hopefully you'll agree that even if nothing is wrong with the code that runs the
> commands, that the output is confusing at best, and misleading at worst.

It's because internally, the "git credential-store get" command is assembled as a single string passed to the shell, whereas remote-https is run directly via exec/spawn.

I agree the output is confusing.

That may give us a clue as to what's going wrong, though. I.e., there could be some issue with the shell on your system.

> Hopefully you won't fault me for just wanting something that works, so I am just
> going to use my AskPass program [2] that I wrote in response to this situation.
> Ironically, "git push" is actually faster now than it was with Netrc, so I guess
> that's a win. Thanks for the responses.

Nope, that's definitely your right if you don't want to spend time digging further. But as I can't reproduce here, it may mean the problem goes unsolved. We do have tests for credential-store in our test suite, so if it were broken for everybody, I expect we'd have noticed. If it is specific to your system somehow, then you working around it is as good as a solution. :)

-Peff
Steven Penny· Nov 4, 2021, 14:12 UTC · re: Jeff King · lore

Re: credential-store get: No such file or directory

On Thu, Nov 4, 2021 at 4:43 AM Jeff King wrote:
> It's because internally, the "git credential-store get" command is
> assembled as a single string passed to the shell, whereas remote-https
> is run directly via exec/spawn.

Actually, I bet that is whats causing the problem. I am using MSYS2 Git [1], which is not a native Windows build of Git, but one that relies on the MSYS2 DLL for path translations and such. I have actually built a Windows native Git, but its a pain, so its easier just to use the package. Anyway, the "non native" Windows version, probably considers Bash the shell, so any commands being passed to a shell probably will be looking for Bash. I dont have Bash on my system, because for the most part I dont want or need it. If I need a shell, I just use PowerShell.

Would it be possible for Git to just run "credential-store" directly, like other commands? I assume stuff like "~/.git-credentials" would be a problem, but couldnt you just do something like this instead (pseudocode):

    var cred string = os.Getenv("HOME") + "/.git-credentials"
1. https://packages.msys2.org/package/git
Jeff King· Nov 4, 2021, 14:55 UTC · re: Steven Penny · lore

Re: credential-store get: No such file or directory

On Thu, Nov 04, 2021 at 09:12:39AM -0500, Steven Penny wrote:
Show 13 quoted lines
> On Thu, Nov 4, 2021 at 4:43 AM Jeff King wrote:
> > It's because internally, the "git credential-store get" command is
> > assembled as a single string passed to the shell, whereas remote-https
> > is run directly via exec/spawn.
> 
> Actually, I bet that is whats causing the problem. I am using MSYS2 Git [1],
> which is not a native Windows build of Git, but one that relies on the MSYS2 DLL
> for path translations and such. I have actually built a Windows native Git, but
> its a pain, so its easier just to use the package. Anyway, the "non native"
> Windows version, probably considers Bash the shell, so any commands being passed
> to a shell probably will be looking for Bash. I dont have Bash on my system,
> because for the most part I dont want or need it. If I need a shell, I just use
> PowerShell.
OK, that would explain it, I think.
Show 5 quoted lines
> Would it be possible for Git to just run "credential-store" directly, like other
> commands? I assume stuff like "~/.git-credentials" would be a problem, but
> couldnt you just do something like this instead (pseudocode):
> 
>     var cred string = os.Getenv("HOME") + "/.git-credentials"
Possible yes, easy no.

The "~" part is trivial; that's expanded inside the C program anyway. The harder thing is that helper strings can be arbitrary shell commands (if you start them with "!"), so we decide at parse time whether to stick the "git credential-" in front and then always treat it as a shell command, rather than carrying through the knowledge that it doesn't need a shell. So switching that would ripple through the whole call stack and the data structures.

Definitely not impossible, and not even _hard_, but it's not like a one-liner change.

-Peff

← back to recent threads