3

Whenever I run the flutter or dart commands on the command line or PowerShell I get "Error: Unable to find Git in your PATH".

I've already tried to the solutions from other suggestions like making sure the PATH contains:

  1. C:\Windows\System32
  2. C:\Windows\System32\WindowsPowerShell\v1.0
  3. C:\Program Files\Git\bin and/or C:\Program Files\Git\bin\git.exe
  4. C:\Program Files\Git\cmd
  5. C:\src\flutter\bin

I reinstalled flutter and still does the same.

I reinstalled Git and tried it on the command line and Git works.

I'm using VS Code and Windows 11, any suggestions?

enter image description here

JorgeZ
  • 168
  • 8
  • 1
    `C:\Program Files\Git\bin\git.exe` PATH must be a list of directories, not files! – phd Apr 01 '23 at 14:49
  • 1
    @phd Yes, I know the PATH is an environment variable which contains a string of text holding a list of directories separated by semicolons and are not files, however I wanted to try C:\Program Files\Git\bin\git.exe because I've seen it like that in other suggestions, I did get rid of it afterwards. – JorgeZ Apr 01 '23 at 14:59
  • What does `Get-Command git -All` report in your VS Code PowerShell session? Does `$env:Path` report a different value than `path` in `cmd.exe`? – mklement0 Apr 01 '23 at 20:30
  • @mklement0 Check the image I added, you'll see to see the response to your questions... $env:Path and %path% have the same value. – JorgeZ Apr 02 '23 at 19:56
  • Mysterious - I'm out of ideas. [This answer](https://stackoverflow.com/a/68414006/45375) offers methodical troubleshooting tips, but I'm not sure it has something to offer that you haven't already tried. – mklement0 Apr 02 '23 at 20:39

1 Answers1

0

I had this problem. Adding paths to Path(System variables):

C:\Program Files\Git\bin
C:\Program Files\Git\cmd
C:\src\flutter\bin

helped solve the problem.

-> Also, try rebooting the computer for the changes to take effect

-> Run cmd/PowerShell/Android Studio as administrator

Moreover, I use the git portable version.

Ruble
  • 2,589
  • 3
  • 6
  • 29
  • @Ruble I've already added the paths to PATH... I use VS Code... I'm running the flutter and dart commands from VS Code and from the command line and/or powershell... I rebooted the computer and still get the error... You use the portable version of what? – JorgeZ Apr 01 '23 at 14:51
  • @phd Yes, I know the PATH holds a list of directories not files. – JorgeZ Apr 01 '23 at 14:54
  • It was meant that the git is installed portable... – Ruble Apr 01 '23 at 17:25