# git config credential.helper with absolute path on windows not working properly

2 messages from 2015-10-05 to 2017-09-26. Participants: Valentin Stanciu, bcampolo.
Thread: https://gitlist.dev/t/40490

## Valentin Stanciu, 2015-10-05 20:40

Subject: git config credential.helper with absolute path on windows not working properly
Message-ID: <CADmzSDHbH-=bX=PFqvoe23iQPF7Mq6ogV7D9c0XjdXUsORgmBQ@mail.gmail.com>
URL: https://gitlist.dev/e/CADmzSDHbH-%3DbX%3DPFqvoe23iQPF7Mq6ogV7D9c0XjdXUsORgmBQ%40mail.gmail.com

```
Hey guys,

I recently found that specifying absolute paths for credential helper
on windows does not work correctly if the path has spaces or non
alphanumeric characters like parentheses. From what I gather it seems
to do with how args are passed to subprocesses.

example:
git config credential.helper "C:\tmp\a (b)\git-credential-helper.cmd"

Running `git config credential.helper` shows that git got the full path:
C:\tmp\a (b)\git-credential-helper.cmd

However, when running `git push`, for example, git has problems
invoking the credential helper. If the path has no spaces or
parentheses, then everything is fine.

I tried countless ways of escaping the path, but couldn't find a
proper way to pass this to git and make it work. Tried adding more
quotes, slashes, and '^' (escape character for batch). Escaping spaces
with slashes seems to work, but couldn't find a way to escape
characters like '(' and '('.
I think git needs to add some escaping or quotes when running the
credential helper.

This affects commands that inline the credential helper too:
git clone https://path.to.repo.com C:\tmp\default --config
credential.helper="c:\tmp\a (b)\git-credential-gcloud.cmd"

Not sure if this is limited to credential helper or any config in git,
but this is a case I could repro easily.

Tested on Windows 7 x64 with all updates installed, from the command
line, using git version 2.6.0.windows.1. Git is installed to be
available from the command line.


Thanks,
Valentin

```

## bcampolo, 2017-09-26 14:51

Subject: Re: git config credential.helper with absolute path on windows not working properly
Message-ID: <1506437512234-0.post@n2.nabble.com>
URL: https://gitlist.dev/e/1506437512234-0.post%40n2.nabble.com
In-Reply-To: <CADmzSDHbH-=bX=PFqvoe23iQPF7Mq6ogV7D9c0XjdXUsORgmBQ@mail.gmail.com>

```
My situation was a little different, but I was able to get this to work with
some interesting escaping.

helper = !"\"C:\\Path with spaces\\executable\"" --option1 value1
credential-helper $@

Notice the exclamation, quoted path of executable and extra escaped quotes
inside of that, plus escaped backslashes.






--
Sent from: http://git.661346.n2.nabble.com/

```
