Can't find pub/cache folder in %LOCALAPPDATA% - flutter

I am trying to make pub an environment variable. The dart.dev says it must be in user/AppData/roaming folder named as pub I looked in roaming, local and locallow folders but there is not such a directory. The dart itself is installed with flutter sdk I looked in the folder too there is a folder named bup-cache but it does not have a pub.bat or pub.exe file as far as I saw.
Pub get itself works fine when i use it with flutter on VSC IDE but I can not locate the folder to make it environment variable.
Can you guys help me find The pub folder?
Thanks in advance
and be cool I'm a newbie

You have to go inside of this folder on Windows:
C:\Users\YOUR_USER_NAME\AppData\Local\Pub\Cache
Maybe you cleared the cache and that's why you cant find it

well i got it sorted out in a way the folder was not there and i needed it to use stagehand.
I simply ran a code in CMD or whatever shell which let to solution it was:
dart pub global activate stagehand

Related

Weird output from "flutter clean" command when used outside folder that has build

When i run flutter clean a folder outside the main build folder. I this response:
Changing current working directory to: /User/..
Why is that? and what does working directory refer to? How do i know my old one?
There needs to be a yaml file for flutter clean to work correctly.
That was my mistake.

Could not create task ... this and base files have different roots

I've built an app with Android Studio and Flutter and wanted to generate a signed APK.
When I go to Tools->Flutter->Open Android module in Android Studio, it starts to build the project.
But after some time I get this Error and I don't know how to change the roots or what to do.
It seems like the problem are just two packages (url_launcher and shared preferences)
My Project is on my hard disk F:
and the flutter folder is on my hard disk C:
Error Message "Could not create task..."
Is this maybe because my project is on F: and the flutter folder with the packages in C: ?
How can I change the flutter folder to F: ?
I fixed mine by moving the project directory to the same drive. My project was stored in E:\ so, I moved it to C:.
My answer is almost the same as rvr93's answer but I did not add anything to the environment variables.
Create a directory in the same drive as your project and add PUB_CACHE environment variable. Run flutter pub get.
This worked for me.
I had your same issue, Gradle couldn't sync the android module, I solved it by deleting the android/ directory from the Flutter project, then recreate it using the command flutter create --platforms android .
Notice the "." at the end of the command it's part of it, it means create the Android project in the current directory.
As a workaround, you can do the following steps -
run flutter clean
do the Gradle sync without flutter pub get and make necessary changes to
native android code.
do pub get and run the app.
I have the same issue,
it seems the flutter project and the SDKs are in different prtitions of the hard disk
just go to the project root and run flutter clean
then go to the android folder and delete the .gradle folder
then back to the project root and run flutter pub get
and rebuild the app
As a workaround, you can do the following steps :
Open a terminal.
Run flutter clean.
Do the Gradle sync without flutter pub get and make necessary changes to native Android code or click on try again.
Do flutter pub get and run the app.
You will see that the SHA1 has been generated.
I faced the same issue in my android project after upgrading gradle.
My project was in my D drive, and I had set the destination folder for the generated apk in my desktop, which is in C drive. I changed the destination folder to a folder in D drive, and the issue got resolved.
I was facing the same issue all I did was to go build.gradle file in android folder and then change the following code as follows
dependencies {
//CHANGE THE Version in YOUR BUILD.GRADLE FILE
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
This is a temporary solution - track status here

Can't load Kernel binary: Invalid SDK hash in Flutter

Whenever I try to run a dart tool like Dart Migrate I get the following error and I am unable to run that tool. Is there a way to solve this problem or I have to reinstall Flutter?
Btw every thing is okay with Flutter Doctor
After a lot of effort and wasting a lot of time on this issue I have been able to solve this problem. I have installed dart-sdk separately in the past and place the path of that dart-sdk at the top (before flutter one) in environment variables PATH. So I deleted that old dart-sdk path and deleted the respective folder this solved my problem.
In VS Code, if you get "Can't Load Kernel binary: Invalid SDK Hash" in Flutter or Dart, update dart.sdkPath setting
If you get this in VS Code, in addition to re-downloading the dart-sdk, make sure the "dart.sdkPath" setting in user/workspace settings is pointing to the new SDK. In my case, even though I had it in my path as in Junaid's answer, VS Code was still looking to the old dart-sdk folder and giving me the kernel hash error. I updated the dart.sdkPath to the correct path and restarted VS Code:
For example, in Windows:
Download dart sdk
Unzip it to c:\tools\dart-sdk or any other folder (make sure you rename or delete the existing dart-sdk folder)
ctrl-shift-p, type 'user settings (JSON)', open the json settings, and add:
"dart.sdkPath": "C:\\tools\\dart-sdk",
Update your system PATH environmental variable to point to the new dart-sdk and delete the reference to the old location.
Restart VS Code.
Note that Instead of This "dart.sdkPath": "D:\Dart\dart-sdk\bin" work well for me.
path should be included '\bin' also. It work for me

'flutter doctor' returns '\flutter\bin\cache was unexpected at this time.'

I have downloaded flutter_windows_1.17.1-stable and extracted it outside the program files, yet whenever I run the 'flutter doctor' command I am getting the message '\flutter\bin\cache was unexpected at this time.'
I have searched about this and found few solutions suggesting to delete the cache folder in bin of flutter directory, I did that, also added the path in environment variables, still having the same message.
Please, I need suggestion on how to fix this.
Thank you.
Faced similar issue, I initially created C:\Program Files(Manual)\Flutter
and added to user env path variable, but got Cache error, only when I moved to c:\src\Flutter it worked, I'd say paths with spaces (and or special chars '(' ')' ' ' aren't accepted
While you're using windows, go to the system environment variables from the search and edit flutter path variable, change it to the binary folder like C:\src\flutter\bin.
When I ran into this issue, I had already installed flutter several times to fix previous errors. This issue can happen if flutter is not installed in your environment variables, but it also happens if there is another duplicate or path to another bin in the same host. Also, make sure to check on all places for duplicate paths to two or more flutter bins. There are environment variables for your account, and environment variables for the entire PC. Be sure to check in both
Make sure you extract all your files to c:/src/flutter
If the problem is still there , then to run commands use c:/src/flutter/bin
I.e., include bin to your path
I had the same issue. I tried all the above solutions, but they did not work. So I also changed the path. The solution was to direct the CMD to Flutter's main directory.
Example: You want to run the code flutter doctor. You expect to open the CMD and run the code, so you get the result while you have configured the env and path, but it does not. To run the code, go to the same directory you installed the flutter and then run your codes;
E:\Program Files\flutter> flutter doctor
I hope it works for you as it worked for me. GL
1.) Move the Flutter folder to your C Drive.
2.) Create a new Folder called "src".
3.) Move Flutter folder to src.
4.) Add C:\src\flutter\bin to Path in Control Panel -> User Accounts -> Enviorments -> Path -> edit
first if you changed your flutter's location and if you gave path again to variables, you you need to dalate old path of flutter and it works.

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!