Could not find a file named "pubspec.yaml" in

run flutter clean and then flutter pub get


I was facing a similar issue when running even a simple dart run:

Could not find a file named "pubspec.yaml" in '/Users/<username>/.pub-cache/hosted/pub.dartlang.org/animated_widgets-1.1.0'

So I managed to fix it by these steps:

  • sudo rm -Rf /Users/<username>/.pub-cache.
  • flutter clean in the current project folder.
  • MOST IMPORTANT run dart pub get
  • flutter pub get

And it finally worked 🤗


This has happened to me several times:

What's ultimately solved things for me (OS X) is deleting pub's cache:

sudo rm -Rf /Users/<username>/.pub-cache

Also, delete the packages directory in your project's root:

sudo rm -Rf .packages

Then pub get again in your project(s), but make sure that you are not operating as root (a whoami will tell you, and an exit will get you out of there).

Tags:

Dart

Dart Pub