Flutter - running command "flutter _____" instantly closes terminal
Asked Answered
M

20

13

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

Mountain answered 30/9, 2020 at 5:33 Comment(0)
C
27

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

Caption answered 22/3, 2021 at 14:49 Comment(0)
J
8

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

Jeuz answered 24/4, 2023 at 7:40 Comment(0)
R
7

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%"
Rozalin answered 16/11, 2021 at 19:35 Comment(0)
S
4

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.

Seychelles answered 1/1, 2021 at 10:23 Comment(0)
A
4

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

Algology answered 2/4, 2021 at 8:28 Comment(2)
What is check power shell. to mean? How does this improve on SUDHANSHU SHARMA's Mar 22 answer?Carboni
Power shell path in system variablesAlgology
T
3

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

Trebuchet answered 2/2, 2023 at 20:37 Comment(0)
B
1

Add only these routes in the path parameter (in your environment variables) and it will surely work. ONLY FOR WINDOWS

Environment variables on Windows

Biysk answered 24/3, 2022 at 17:36 Comment(0)
R
1

Try this:

  1. Moved flutter from C:/ drive to D:/.
  2. Update the environment variable of flutter.
  3. Reboot the machine.
Rebak answered 7/3, 2023 at 15:27 Comment(0)
S
0

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.

Salford answered 30/9, 2020 at 5:43 Comment(0)
S
0

Download Flutter SDK again and change your Flutter SDK path and update new path in environment variable and restart your IDE

Sapphirine answered 26/8, 2021 at 13:21 Comment(0)
D
0

The problem is of powershell only. In my case I mistakenly used ; at the end of path which was creating problem.

Dudden answered 25/9, 2021 at 21:54 Comment(0)
T
0

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.

Totten answered 10/11, 2021 at 14:22 Comment(0)
L
0

You have to do the following and the issue will be resolved.

  1. 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>
  2. 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.

Lymphangial answered 27/2, 2023 at 20:1 Comment(0)
D
0

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.

Doronicum answered 5/3, 2023 at 19:41 Comment(0)
A
0

my problem solved with:

git config --global --add safe.directory '*'
Ahoy answered 8/6, 2023 at 2:6 Comment(0)
D
0

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...

Doig answered 24/9, 2023 at 22:56 Comment(0)
B
0

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.

enter image description here

enter image description here

Buttress answered 14/12, 2023 at 13:12 Comment(0)
N
0

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.

Nike answered 1/1 at 8:20 Comment(0)
M
0

I solved this by just installing Git. Which was not in my environements variables

Miller answered 5/8 at 13:23 Comment(0)
C
-2

I have the solution

  1. go to C:/ in windows
  2. create a src folder
  3. into your src folder run this git clone -b stable https://github.com/flutter/flutter.git
  4. setup your env variables with this path= C:/src/flutter

problem solved!

Chetchetah answered 17/4, 2022 at 3:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.