INFO: Could not find files for the given pattern(s) doing `where git`

Viewed 778

I have git installed under C:\Program Files\Git\ I do the following from a setupenv.bat:

set PATH="C:\Program Files\Git\bin";%PATH%

So doing the following I can see it:

echo %PATH%

The following will then work:

git --version
>git version 2.21.0.windows.1

But this won't:

where git
>INFO: Could not find files for the given pattern(s)
1 Answers

The issue, is most likely that you have surrounded your location string with double-quotes.

The locations listed within the %Path% string value content are delimited with semi-colons, for that reason your intended addition to that value content should not be double-quoted.

If you take a look at the existing %Path% content, by typing Path at the Command Prompt, and pressing the ENTER key, you'll note the absence of double-quotes, and most likely that there are paths which include space characters.

The solution therefore is to change your set command from:

set PATH="C:\Program Files\Git\bin";%PATH%

to:

set PATH=C:\Program Files\Git\bin;%PATH%

However, I will add that the recommended syntax for the Set command is:

Set "VariableName=Variable Value"

So you should really write it thus:

Set "PATH=C:\Program Files\Git\bin;%PATH%"

It should be noted too that the locations listed within the value of Path are searched in order, which means that you should consider carefully whether your new location should be located and therefore searched first, or last. The precedence could be important depending upon what else is being done within that script.
As the Path value string should already be semi-colon terminated, you could just as easily locate it at the end:

Set "Path=%Path%C:\Program Files\Git\bin;"

Also note that there is already an environment variable available for the normal \Program Files\ directory, so you could additionally incorporate that instead:

Set "Path=%ProgramFiles%\Git\bin;%Path%"
Related