1

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:

  • included all essential git paths i.e.

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

  • (did the above step many times , restarted computer and tried again = fail )

  • checked flutter bin path

  • tried running cmd as administrator

  • tried running command in flutter console

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 .

Savvy
  • 51
  • 2
  • 8

2 Answers2

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • ( The git.exe was removed after i reinstalled git ) – Savvy Jun 01 '20 at 14:18
  • I entered the mentioned commands and now I have a different error:'flutter' is not recognized as an internal or external command, operable program or batch file. – Savvy Jun 01 '20 at 14:18
  • 1
    @Savvy Sure: add the path of flutter as well. `set PATH=C:\path\to\Flutter;%PATH%` – VonC Jun 01 '20 at 14:20
  • I already added the following path C:\Users\Flutter\flutter\bin ...gave the above command but still same error..I've also added a screenshot of cmd error in the post – Savvy Jun 01 '20 at 14:26
  • @Savvy Try the same set of commands in a new CMD (in which "where" is recognized) – VonC Jun 01 '20 at 14:37
  • No no , it didn't work ( my system got incredibly slow so I reinstalled windows overnight , now after setting everything , I have installed flutter and git again and same error, I tried PowerShell too , it's the same "where" error) – Savvy Jun 02 '20 at 07:52
  • 1
    @Savvy In your screenshot, you used `set GH=C:\path\to\git`: you did replace `C:\path\to\git` by your actual Git installation folder, right? – VonC Jun 02 '20 at 07:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/215146/discussion-between-savvy-and-vonc). – Savvy Jun 02 '20 at 08:06
  • 1
    Worked for me. I needed to set it in the console like above rather than manually through the environment variable interface in windows – user1619480 Apr 15 '21 at 10:57
1

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
Narain
  • 872
  • 9
  • 11