Flutter Command - Powershell.exe not in PATH error message - flutter

I have flutter installed and everything works fairly alight but every time I run a flutter command I get the following message before the command actually runs.
Error: PowerShell executable not found.
Either pwsh.exe or PowerShell.exe must be in your PATH.
I added the Powershell.exe path to my PATH variable (both System & User) and also added C:\Windows\System32 as I read that on one of the Github/SO forums. Any idea how to get rid of this? I am following a Udemy course and have followed every instruction to the dot but the instructor does not get this message.

Go "Edit environment variables for your account" under "User variables" add to Path this line
C:\Windows\System32\WindowsPowerShell\v1.0
It solved my problem.

Add this to user Path variables and system path variables
C:\src\flutter\bin
Add these to Environment System Path Variables
C:\Program Files\Git\cmd
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32
My problem was the missing of 3rd from System path variables.

I have lost half a day to solve it and used all instructions on flutter site and and answers about powershell path. It didnt work until add C:\Windows\System32 to Path variable.

copy the path, for my case, it is "C:\Windows\System32\WindowsPowerShell\v1.0" and pastes it in environment variables as a path

In case you encountered this problem and none of the above solutions worked for you. In my case, I set all the environment variables - I am using Windows 10. I even reinstalled flutter; but the problems persisted.
It turns out my Anti Virus had quarantined the Powershell executable file. I had to open the anti virus quarantine chest, restored the Powershell executable and restarted my VS Code.
Problems solved, after three days of searching for solutions.

Related

Changed Starting Path with PowerShell Profile But Cannot Change it Back

While learning Anaconda I had a problem with "cd" not working in Anaconda PowerShell, so I did what is recommended here, manually created a profile and set the path to a specific folder. It worked.
But today somehow I found "cd" is working for me again, so I was going to delete that ps1 file. But the folder together with the file in that was no loner there, completely gone. Now I am stuck with my temporary path on every PowerShell start-up.
According to Microsoft documentation, $profile should return my profile variables, which it did:
C:\Users\myname\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
But first, this is not the file name I gave it; second, this path is also non-existent, both folder and file.
I tried notepad $profile, then Notepad told me "The system cannot find the path specified." But it is exactly the path the system told me.
Some answer I saw here says that is because my profile is non-existent, I need to create one first. That is not the case here. I definitely overwrote my starting path, but I cannot find the actual profile file to edit that back.
I also tried doing it the same way again but changing "YOUR_FILE_PATH" into "%Home" hoping to "overwrite" it back, yet somehow this time it did not work and the file did not disappear as it did the first time.
I am really confused on this.
If you want to reset PowerShell to the original settings when PowerShell was installed.
Uninstall PowerShell from the Add or Remove Programs.
Restart your computer.
Reinstall PowerShell.

Powershell problem when changing channel from Stable to Master in Flutter SDK

After changing the Flutter SDK channel from Stable to Master I now get this error when running Flutter commands:
Error: PowerShell executable not found.
Either pwsh.exe or PowerShell.exe must be in your PATH.
Add powershell.exe to your path in environment variables. You can find it under:
C:\Windows\System32\WindowsPowerShell\v1.0
Go to System Properties -> Advanced System setting -> Environment Variable -> User variables - > Path
Add powershell.exe to your path in environment variables. You can find it here
C:\Windows\System32\WindowsPowerShell\v1.0
I ran into this issue as well and was able to solve it as mentioned by #pallav-bohara and #ashirbad. But just wanted to add some complementary configurations you might need as well. Following procedure tested in Windows 10:
Add this to the User-level environment variable PATH, if you don't have:
C:\Windows\System32
Add PowerShell path to User-level environment variable PATH, as Flutter tools depends on PowerShell 5.0 and above.
But better place the paths of Step-1 & Step-2 before flutter or npm path:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
Note: Of course, you should also ensure to have your flutter bin correctly set.
I actually found this solution here which saved some valuable time and wanted to summarize all the important points.
Solved my problem after installing Windows Management Framework 5.1
Link:
https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616.

Overriding extensions directory in vscode

One can specify the extension dir by running from command line:
code --extensions-dir c:\path\to\ext
However, I would like to set this parameter even when running from the windows menu.
I tried to modify the argv.json file located in the .vscode folder (like for https://code.visualstudio.com/docs/getstarted/locales).
It didn't work.
Does anybody know how to fix this?
Bests
Try creating an environment variable called VSCODE_EXTENSIONS with the value of c:\path\to\ext
As a complement to DG's response
If the VSCODE_EXTENSIONS environment variable is created as a system variable, it seems to affect all users.
In my case, I performed the following steps:
close VSCode on all users (I usually have one session open as
administrator and another as non-administrator)
set the variable VSCODE_EXTENSIONS = c:\ProgramData\Code\extensions\
moved all extensions from the extensions folder of the administrator to c:\ProgramData\Code\extensions\
restart the computer
log in with both users and the extensions were available
It is convenient to mention since then the extensions installed by administrator are available to all users and are installed in the folder mentioned previously.

Flutter installation not working?

I have installed the flutter folder in Program Files (x86) and have added the .../flutter/bin directory to path. Running flutter doctor in the flutter_console.bat window or just a normal command prompt window gives nothing
and running as admin in either gives me the error:
Updating flutter tool...
\flutter\.pub-cache was unexpected at this time.
What do I do? Thanks in advance for any help.
You shouldn't put Flutter in Program Files. These folders are not writeable by non-Admin users so may fail when trying to write files if you're not running your console/editor as Admin.
Cut flutter folder from Program Files (x86) to Program Files. It has problem with x86 but works fun in x64 directory. And update the environment variables with the new path.
I had mine fixed by just removing the special character from the directory name.
I organize my folders with numbering and parenthesis like so
1) xyz
2) yza
3) aws
...
25) flutter
I changed it to
1) xyz
2) yza
3) aws
...
25 flutter
don't forget to change it in environment variables too
Ok so this is probably not the way to go about it but what I did to solve this problem was remove this line
SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache
from flutter/bin/flutter.bat. I then went through the installation process and once everything was working changed the flutter.bat file back by adding the line again and then ran flutter again. I got no errors from doing this and I appreciate that this is probably not the correct way to go about solving this problem but it worked for me so I am posting it as the answer if others want to try it.
1.Set the environment variable by copying the bin directory ex: C://programfiles/flutter/flutter/bin
2.Go to Control panel -> User Accounts -> User Accounts-> Change environment variables -> Choose User variable -> Path -> Edit -> New -> Paste the link -> click ok
3.Restart Computer -> Open powershell -> Type "Flutter"
4.It should be working now.
1- First make sure that you running cmd or powershell as admin.
2- If didn't work try to restart PC.
3- If didn't work try to move the flutter folder to another path and make sure that you did the required changes on Environment Variables.
4- If didn't work, just delete the cache folder in "flutter\bin" and try again by writing
flutter doctor
Also as a note, try not to put your flutter directory inside the special directories which need a special permissions like Program Files.
I had originally installed it in d:\Program Files (x86) which is NOT the system folder, but an alternate install location that does not require elevated privs, and I was getting this error. I moved flutter to just d:\flutter and it worked. I don't know if it was spaces or the parentheses that was problematic.
Extract the zip file and place the contained flutter in the desired installation location for the Flutter SDK (for example, C:\src\flutter; do not install Flutter in a directory like C:\Program Files\ that requires elevated privileges).
You are now ready to run Flutter commands in the Flutter Console!

xcopy is not recognized as an internal or external command, operable program or batch file

I have a problem using 'xcopy' command.
I'm building a C# project with msbuild. At the end of the build, a batch file is called to copy my assemblies from Debug/Release to some other folders.
Here is the problem, my build fail and the error log is 'xcopy is not recognized as an internal or external command, operable program or batch file'.
The path is correctly set, xcopy do works from a windows command line and from the visual studio command line (the one set with the project environment).
I tried to set the path in the batch file but it doesn't help.
Any suggestion?
I'm using windows 7
Cheers :)
I encountered the same problem.
It seems to be a problem with the path environment variable within Visual Studio.
When I added a "path" statement to the beginning of my build event, it produced the following output:
PATH=
This seems to indicate that the path is empty within the VS build environment.
When I specify the full path to xcopy like this, the problem went away:
%systemroot%\System32\xcopy ...
I'm not sure what caused Visual Studio to lose it's path.
Set Environment variable PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
This is not a problem with Windows 7 or 8. It's actually a problem with applications that update environment variables such as PATH.
The PATH is stored in the Registry as an "Expandable string value" (REG_EXPAND_SZ), but a lot of applications write it back to the Registry as a "String Value" (REG_SZ). If your path contains anything like %SYSTEMROOT%, this will not be expanded into C:\Windows (or whatever yours is) if the path is stored in a REG_SZ.
The fix is simply to edit your path manually from the control panel. You need to make a change (eg add a ; to the end of the path) and then apply it. This will fix up your path in the Registry to be a REG_EXPAND_SZ.
(Go to the System Control Panel and select Advanced System Settings. Edit the Path Environment variable in the lower box, and that should fix it.
You can tell whether your path is broken in this way by opening a command prompt and typing PATH. Your path will be listed. If you can see anything enclosed in % % then your path is not being expanded.
It happened to me after I updated one of my Visual Studio extensions, during which Visual Studio was closed and reopened by the updater. I could no longer properly build my project. I closed Visual Studio and reopened it and the problem went away.
I just experienced this for the first time with a batch file I use to copy an Access front-end app to the user's local machines. Their environment is a mix of Windows 7 & 8 and 32-64 bit machines. I noticed that the xcopy.exe was both in the System32 and the SysWOW64 folders and I wondered if there was some conflict. So -- I copied the xcopy.exe into the folder where the batch file resides and it now seems to be working. Just thought I'd share this.
Eileen
I also had a problem with xcopy (same error message) - with a very simple batch program that I use to backup files to a removable drive. Have been using that program for at least 5 years with never a problem. Then yesterday xcopy is unknown to Win7. The replacement of xcopy with %systemroot%\System32\xcopy at each instance solved the problem. Very strange.
Go to environment variable and correct PATh including ; in last.
It will work, this is not at all related to OS or Technology.
It's working for me, Not even need to restart OS, Just open new command prompt.
[Fixed for me]
After adding the correct paths to "Path" environmental variable it still doesn't work (for cmd and VisualStudio) (even after restarting the PC).
The problem was in broken register parameter:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
ParameterName=PATHEXT
I had the value .wlua;.|exe. Maybe was broken after installing something.
Everything works again after changing it to:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Hope this helps if nothing other works.