144

I erased in my folder .pub-cache/hosted/pub.dartlang.org/this_plugin

What is the command to update the dependencies inside pubsec.yaml? I believe it is

flutter packages get

The folder under .pub-cache is still not up to date.

Note: there was a pubspec.lock that I deleted

10 Answers 10

277

Disclaimer: By running the command below, have a really fast internet connection or be ready to lose one hour of productive hours. ( it will redownload every package every installed on your pc, and I mean each and all of the versions of each packages)~TSR

flutter pub cache repair 

or delete /Users/xxxxxxx/development/tools/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+3/ and run flutter packages get again.

if all the above things fail delete the cache folder or also check the version updated in the lock file (some time lock give me the problem with updating the version number)

PS: Why flutter pub cache repair download every package version previously used?

Sign up to request clarification or add additional context in comments.

2 Comments

Failed to reactivate dartfn 0.4.4: Could not find a file named "pubspec.yaml" in "/Users/yogiarifwidodo/.pub-cache/hosted/pub.dev/dartfn-0.4.4".
try flutter pub upgrade before running repair
98

Remove the package from dependencies in pubspec.yaml, run flutter packages get. And then add the package to dependencies again and running flutter packages get.This process has solved the problem for me in the past.

5 Comments

@jesses.co.tt Yes, LOG_TAG's answer explains why this works and a better legit way of doing this.
won't work if you changed some file of package, as on pub get it will first check-in cache better to use flutter pub cache repair
It will not work in all cases, try running , flutter pub cache repair
Was skeptical at first, I don't know how, but this worked like magic 100%.
Although this is worked for me for most of the times, sometimes it doesn't work. In my case I was adding lets say the version 1.1.alpha-1.0 on my pubspec, but I was still getting the version version 1.1.alpha-2.0, even with the above trick. What helped me was to go to pubspec.lock and change there the version to the desired one. Then flutter pub get got me the right version.
84

Delete the pubspec.lock file then run the command flutter pub get again.

3 Comments

This approach resolved my problem with syncfusion_flutter_calendar plug-in
This approach resolved my problem with the syncfusion_flutter_pdfviewer plugin, thank you very much!
Tried, did not work for me
63

Clearing the projects cache

You can empty the entire projects cache to reclaim extra disk space or remove problematic packages.

run flutter pub cache clean in terminal at project directory

1 Comment

It works fine. is is better than others.
23

The below steps worked for me.

Flutter installation corrupted
The Flutter install directory is in an inconsistent state and that causes all kinds of troubles.

Causes
Unclear

Ways to fix
Run the following commands in the Flutter install directory:

git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor

Corrupted cache
Especially with plugin packages, it was seen several times that the package in the pub cache was corrupted.

Symptoms
Usually syntax errors at build time about code in dependencies.

Causes
Unknown.
IDEs or editors used by developers might not prevent editing plugin files and when they navigate into plugin code they might accidentally modify the code.

Ways to fix

Run flutter pub cache repair
This might take quite some time and re-downloads every package in the cache, even outdated versions that might not be used anymore by any project on disk.

Delete ~/.pub-cache/hosted and/or ~/.pub-cache/git (for Git dependencies). This requires running flutter packages to get in all active projects on your machine afterward.

Delete a specific package or package version. Look up the exact path in the cache for a specific package in the .packages file of your project. For example for firebase_auth

Reference: https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted

1 Comment

First need to commit because I did lost my changes. by running your commands
6

Error: Found an existing Pub cache at ... It can be repaired by running dart pub cache repair. It can be reset by running dart pub cache clean.

Solution: Run following command in the flutter project directory dart pub cache repair then dart pub cache clean and then flutter pub get

Comments

4

run

flutter clean

flutter pub cache clean

delete pubspec.lock file then check again

Comments

3

Please run the following command in the terminal for Mac users:

open ~/.pub-cache/hosted/pub.dev/

Delete the problematic package folders. Then, run the project again.

Comments

2

I unable to install flutter while installing following error generated Found an existing Pub cache at C:\Users\Lenovo\AppData\Local\Pub\Cache. It can be repaired by running dart pub cache repair. It can be reset by running dart pub cache clean.

Comments

0

You should run flutter upgrade and flutter pub upgrade.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.