A Flutter command says it cannot find pubspec.yaml
Error: No pubspec.yaml file found.Short answer
Flutter and Dart read pubspec.yaml from the current working directory. The error means the terminal, or the folder your editor launched from, is not the folder that holds that file. Change into the project folder that contains pubspec.yaml and run the command again.
Fix it fast
1Find out which cause you have
Print the current folder and list it. pubspec.yaml must be in the listing.
pwd ls pubspec.yaml2Match what you see, then jump to its fix
- 1
Could not find a file named "pubspec.yaml" in a path such as a drive root or your home folderThe terminal is in the wrong folderFix - 2
The command works in your terminal, but fails from the IDE run buttonThe editor started the tool from a parent folderFix - 3
Do no run this command from the root of your git clone.The command was run in the Flutter SDK folderFix
- 1
What does the error look like?
Error: No pubspec.yaml file found.This command should be run from the root of your Flutter project.Could not find a file named "pubspec.yaml"
Cause 1 of 3
The terminal is in the wrong folder
1Check
dart pub get reads the pubspec in the current working directory. After flutter create, the project is in a new subfolder, so staying one level up (or on the drive root) fails.
pwd
ls2Fix
Change into the project folder, the one that contains pubspec.yaml, and run the command there.
cd my_app
flutter pub get3Verify
The command resolves the packages instead of reporting a missing file.
flutter pub getConfirmed by dart.dev
Cause 2 of 3
The editor started the tool from a parent folder
1Check
An editor runs Flutter from the folder it has open. If that is a parent folder of the app, there is no pubspec.yaml there. A stray pubspec.lock or .packages file in the parent can also mislead the editor about where the project is.
ls -a .. | grep -E "pubspec|packages"2Fix
Open the folder that contains pubspec.yaml as the workspace root, and delete leftover pubspec.lock or .packages files in the parent folder.
# from the parent folder, only after checking they do not belong to a real project
rm pubspec.lock .packages3Verify
Run the app from the editor again.
flutter runConfirmed by github.com
Cause 3 of 3
The command was run in the Flutter SDK folder
1Check
The error text itself warns against running it from the root of the Flutter SDK clone. That happens when the terminal was opened inside the SDK directory, for example right after installing it.
pwd2Fix
Leave the SDK folder, create or open your own project, and run the command inside it.
cd ~/projects
flutter create my_app
cd my_app3Verify
The folder you are in lists pubspec.yaml.
ls pubspec.yamlConfirmed by github.com
How do I stop it coming back?
- Open the project folder, not its parent, in your editor.
- After flutter create, always cd into the new folder before running other commands.
- Keep the SDK in its own folder and your projects somewhere else.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
Terminal says pub: command not found after installing Dart
dart: command not found
The standalone pub program no longer exists in current Dart.
2 causes, each with a fixMobile apps
The terminal cannot find the flutter or dart command
zsh: command not found: flutter
The flutter and dart programs both live in the bin folder of the Flutter SDK, so one PATH entry gives you both.
3 causes, each with a fixMobile apps
flutter doctor warns that dart on your path is not in the Flutter SDK
Consider adding C:\flutter\bin to the front of your path.
flutter doctor found a dart program on your PATH that lives outside the Flutter SDK folder, usually a separate Dart SDK installed earlier in the list.
3 causes, each with a fixMobile apps
flutter doctor fails the Network resources check
A cryptographic error occurred while checking
The Network resources check sends a request to a fixed list of hosts and fails if one does not answer.
2 causes, each with a fixMobile apps
Flutter keeps retrying 'pub upgrade' for its own tool
Got socket error trying to find package
The flutter command rebuilds its own tool and downloads packages from pub.dev to do it.
3 causes, each with a fixMobile apps
Terminal says fvm: command not found after installing FVM
zsh: command not found: fvm
The shell cannot find an fvm executable.
2 causes, each with a fix