Savvy
Savvy

Reputation: 51

How to fix "unable to find Git in your path " error , despite providing required path

Whenever i try to run a flutter command (in cmd), the following error occurs :

'where' is not recognized as an internal or external command, operable program or batch file.

Error: Unable to find git in your PATH.

I found the similar error here How to solve "Unable to find git in your PATH" on Flutter? and tried everything

things I've done:

C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd;C:\Windows\System32

None of the above worked as the error still prevails.

EDIT : I uninstalled Git completely , then reinstalled it (choosing the right options) , checked environment variables and everything , gave the flutter command in cmd , and it still shows the same error! I don't know what to do now .

Upvotes: 1

Views: 9113

Answers (2)

Narain
Narain

Reputation: 922

For me this error came for different reason, recording it here so that if someone searches they can benefit.

Firstly I found this error is thrown from this code

https://github.com/flutter/flutter/blob/master/bin/internal/shared.bat#L68

This shared.bat is called by flutter.bat, which is triggered by the flutter daemon. If you see a few lines above, the script tries to just run

git rev-parse HEAD

in the flutter root directory and fails.

When I ran this manually in that folder it threw following error

C:\Users<<>>\fvm\versions\3.7.5>git rev-parse HEAD fatal: detected dubious ownership in repository at 'C:/Users/<<>>/fvm/versions/3.7.5'

Then I just ran the below command suggested along the error by git and it resovled the above error. After this flutter daemon started without any issue

git config --global --add safe.directory C:/Users/<<>>/fvm/versions/3.7.5

Upvotes: 1

VonC
VonC

Reputation: 1327014

A path should not include git.exe, only its parent folder.

See my example if simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

By adding:

set PATH=C:\Flutter\flutter\bin;%PATH%

The OP confirms in the chat that it is working.

Upvotes: 2

Related Questions