Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

A Flutter command says it cannot find pubspec.yaml

ErrorError: 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.

  • Applies to Flutter 3.35, Dart 3.9, Windows, macOS, Linux
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the current folder and list it. pubspec.yaml must be in the listing.

    pwd
    ls pubspec.yaml
  2. 2Match what you see, then jump to its fix

    1. 1Could 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. 2The command works in your terminal, but fails from the IDE run buttonThe editor started the tool from a parent folderFix
    3. 3Do no run this command from the root of your git clone.The command was run in the Flutter SDK folderFix

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
ls

2Fix

Change into the project folder, the one that contains pubspec.yaml, and run the command there.

cd my_app
flutter pub get

3Verify

The command resolves the packages instead of reporting a missing file.

flutter pub get

Confirmed by dart.dev

Did this fix it?

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 .packages

3Verify

Run the app from the editor again.

flutter run

Confirmed by github.com

Did this fix it?

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.

pwd

2Fix

Leave the SDK folder, create or open your own project, and run the command inside it.

cd ~/projects
flutter create my_app
cd my_app

3Verify

The folder you are in lists pubspec.yaml.

ls pubspec.yaml

Confirmed by github.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.