Dealing with some significant frustration trying to set up my environment variables just to run Flutter. in my path, I've tried many suggestions to try setting up my Path route so that the Flutter Console (or cmd) can successfully run the command "flutter doctor" just to download all the packages, etc. But the problem is as soon as I run this command, it instantly closes my terminal. There isn't anything happening, the terminal just closes. Any help would be appreciated, and I've attached my screenshots of my Path envs to maybe help out some more. envs
I also get the same problem i.e whenever I hit the flutter doctor command; the terminal instantly closes. Solution : Add the following to the system variable path.
C:\Windows\System32\WindowsPowerShell\v1.0
everything will work fine
I have tried many solutions from the article but all failed. After I
try this way it works
git config --global --add safe.directory C:/flutter. C:/flutter should be the directory of flutter that you use
Add this to system variable PATH:
C:\Windows\System32\WindowsPowerShell\v1.0
Open cmd as admin and set variables:
setx /M FLUTTER_HOME "C:\flutter" <---- here folder where your flutter is
setx /M PATH "%FLUTTER_HOME%\bin;%PATH%"
I was facing the same issue and I resolved it: the problem was PowerShell version.
I am using Windows 8 and by default it has version 4.
Flutter needs version 5.0, so I upgraded my PowerShell.
Add PowerShell
path to your PATH in environment variables if not exists.
In my case C:\Windows\System32\WindowsPowerShell\v1.0
added to the PATH
in my case non of the answers worked even adding C:\Windows\System32\WindowsPowerShell\v1.0
didn't fix the problem.
the only solution that worked for me is running the command or terminal as an administrator
Add only these routes in the path parameter (in your environment variables) and it will surely work. ONLY FOR WINDOWS
Try this:
- Moved flutter from
C:/
drive toD:/
. - Update the environment variable of flutter.
- Reboot the machine.
Note: Flutter relies on a full installation of Android Studio to supply its Android platform dependencies. However, you can write your Flutter apps in a number of editors; a later step discusses that.
(https://flutter.dev/docs/get-started/install/windows) You could try to install android studio on your machine and try again.
Download Flutter SDK again and change your Flutter SDK path and update new path in environment variable and restart your IDE
The problem is of powershell only. In my case I mistakenly used ; at the end of path which was creating problem.
Perhaps it's like when you run a bat file and Windows closes it because there's no pause command at the end?
When I ran a bat file with the same command from sublime, i saw that it said this in sublime's output...
C:\!\flutter>flutter doctor
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to set up Flutter, run the following command:
git clone -b stable https://github.com/flutter/flutter.git
Solution: Put your folder at C:\flutter. I don't know why but it fixed this. My PATH is C:\flutter\bin. The "location of the sdk" is C:\flutter.
You have to do the following and the issue will be resolved.
- Put the flutter sdk in some other directory other than C:\Program Files or C:\Program Files (x86), recommended Directory is C:\Users<your username>
- now go to the flutter sdk folder. There will be a folder named bin in it. Open the bin folder and copy the path of this folder say: C:\Users<your username>\flutter\bin and add it in the environment variables.
Now close any opened terminal and re-open it and write >flutter doctor it would run properly.
When I first encountered this error, I felt that's the end cause I couldn't seem to find a solution anywhere. They were all pointing to obvious things I've already done. FYI this is my first time posting answer on Stack Overflow
The solution is:
Simply install git Git Download Link and Node js Node js download link and there's no order to this. After this close all IDE or programs using this and try again.
Yeah, that's all it takes.
my problem solved with:
git config --global --add safe.directory '*'
I solved the problem with a totally different method. my problem was with something totally different. but here are some tricks that helped me debug the problem.
- try running the command and saving the output to a log file
flutter > mylog.log
- try running it from powershell, i noticed it doesn't crash the window and actually show info
as for my problem i had the value of ComSpec
(in env. variable) changed by mistake and that prevented any executable file to run (including .bat files which were the problem).
Hope this helps someone...
Windows folder permissions and ownership can also cause the flutter commands to quit and close the commandline windows.
A scenario could be that you format/re-install windows and your Flutter SDK is located on seperate drive from the former installation. The ownership will be different because the reinstallation would have created a new windows account with a different unique id.
Go to the folder properties and click on the Advanced button, if your Ownership has a S- number then you need to retake ownership. Make sure you replace subcontainers and objects as well as permission.
I also had the same issue. But I solved it.
I changed my git version to 2.15.1 through environment variables. At the time that issue occurred, my git version was 2.43.
Then I visited the system environment path variables and replaced its git variable from
C:\flutter\bin\mingit\cmd
to
C:\dev\flutter_3.16.5\bin\mingit\cmd
This path may change your device because it depends on where you place your Flutter SDK. However, remember the following subdirectory sequence inside flutter directory,
\bin\mingit\cmd
Problem Solved! All flutter commands work as usual.
If you've set up your global username and email don't worry. This configuration won't change any of them.
Hope this will help you.
I solved this by just installing Git. Which was not in my environements variables
I have the solution
- go to C:/ in windows
- create a src folder
- into your src folder run this git clone -b stable https://github.com/flutter/flutter.git
- setup your env variables with this path= C:/src/flutter
problem solved!
© 2022 - 2024 — McMap. All rights reserved.
check power shell.
to mean? How does this improve on SUDHANSHU SHARMA's Mar 22 answer? – Carboni