git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* credential-store get: No such file or directory
@ 2021-11-03  0:27 Steven Penny
  2021-11-03  1:19 ` Steven Penny
  2021-11-03  2:25 ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Steven Penny @ 2021-11-03  0:27 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03  0:27 credential-store get: No such file or directory Steven Penny
@ 2021-11-03  1:19 ` Steven Penny
  2021-11-03  2:25 ` Jeff King
  1 sibling, 0 replies; 9+ messages in thread
From: Steven Penny @ 2021-11-03  1:19 UTC (permalink / raw)
  To: git

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)
      }
   }
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03  0:27 credential-store get: No such file or directory Steven Penny
  2021-11-03  1:19 ` Steven Penny
@ 2021-11-03  2:25 ` Jeff King
  2021-11-03  3:57   ` Steven Penny
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff King @ 2021-11-03  2:25 UTC (permalink / raw)
  To: Steven Penny; +Cc: git

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...

> 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.

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03  2:25 ` Jeff King
@ 2021-11-03  3:57   ` Steven Penny
  2021-11-03 11:10     ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Penny @ 2021-11-03  3:57 UTC (permalink / raw)
  To: Jeff King; +Cc: git

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

> 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'

> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03  3:57   ` Steven Penny
@ 2021-11-03 11:10     ` Jeff King
  2021-11-03 16:01       ` Steven Penny
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2021-11-03 11:10 UTC (permalink / raw)
  To: Steven Penny; +Cc: git

On Tue, Nov 02, 2021 at 10:57:09PM -0500, Steven Penny wrote:

> > 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

> > 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03 11:10     ` Jeff King
@ 2021-11-03 16:01       ` Steven Penny
  2021-11-04  9:43         ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Penny @ 2021-11-03 16:01 UTC (permalink / raw)
  To: Jeff King; +Cc: git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-03 16:01       ` Steven Penny
@ 2021-11-04  9:43         ` Jeff King
  2021-11-04 14:12           ` Steven Penny
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2021-11-04  9:43 UTC (permalink / raw)
  To: Steven Penny; +Cc: git

On Wed, Nov 03, 2021 at 11:01:16AM -0500, Steven Penny wrote:

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-04  9:43         ` Jeff King
@ 2021-11-04 14:12           ` Steven Penny
  2021-11-04 14:55             ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Penny @ 2021-11-04 14:12 UTC (permalink / raw)
  To: Jeff King; +Cc: git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: credential-store get: No such file or directory
  2021-11-04 14:12           ` Steven Penny
@ 2021-11-04 14:55             ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2021-11-04 14:55 UTC (permalink / raw)
  To: Steven Penny; +Cc: git

On Thu, Nov 04, 2021 at 09:12:39AM -0500, Steven Penny wrote:

> 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.

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-04 14:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  0:27 credential-store get: No such file or directory Steven Penny
2021-11-03  1:19 ` Steven Penny
2021-11-03  2:25 ` Jeff King
2021-11-03  3:57   ` Steven Penny
2021-11-03 11:10     ` Jeff King
2021-11-03 16:01       ` Steven Penny
2021-11-04  9:43         ` Jeff King
2021-11-04 14:12           ` Steven Penny
2021-11-04 14:55             ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).