8

I'm having some difficulty with flutter within the VS Code tool.

I'm unable to update packages.

$ flutter packages get
Running "flutter packages get" in my_flutter_app...
Could not find a file named "pubspec.yaml" in "/Users/userName".
pub get failed (66)

I'm in the my_flutter_app directory, and clear as day in that directory root there is a file named "pubspec.yaml" . Why is the system looking for pubspec.yaml somewhere else, totally ignoring the pubspec.yaml right there? This doesn't make sense to me.

When I attempt to debug / run the program I get the following response in the Debug Console:

Running "flutter packages get" in my_flutter_app...
Could not find a file named "pubspec.yaml" in "/Users/userName".
pub get failed (66)
Exited (66)

Issue fail on both the terminal within VS code or within system bash terminal. Note: I'm using macOS, High Sierra, 10.13.6

$ flutter --version
Flutter 0.5.7-pre.111 • channel master • https://github.com/flutter/flutter.git
Framework • revision 7ebf2728dc (5 hours ago) • 2018-07-12 14:59:22 -0700
Engine • revision fed2ea458e
Tools • Dart 2.0.0-dev.67.0.flutter-84ca27a09e

Note: the answer from Could not find a file named "pubspec.yaml" in doesn't work here. Tried that, total fail.

zipzit
  • 3,778
  • 4
  • 35
  • 63
  • The linked question/answer is about pubspec.yaml not found in `~/.pub-cache/hosted/.../pubspec.yaml`. Your issue is different and was reported quite often already, but nobody answered any follow-up question in attempts to diagnose the problem. I'd suggest you create an issue in https://github.com/flutter/flutter/issues/new and discuss there. – Günter Zöchbauer Jul 13 '18 at 03:46
  • Did you tried to run flutter packages get with the default podspec.yaml file? – Fran Fox Oct 08 '20 at 17:42

8 Answers8

20

This problem can happen when the main pubspec.yaml references a secondary pubspec.yaml which does not exist.

I met this problem in an example from flutter(vscode, mac os). The answer was found here. After that I did the following:

  1. From the pubspec.yaml deleted:
dev_dependencies:

  image_picker:
    path: ../
  1. Instead, inserted into the pubspec.yaml:
dev_dependencies:

  image_picker: ^0.6.6+4
  1. In the main.dart commented out two lines containing "/src/widgets/":
import 'package:flutter/material.dart';
//import 'package:flutter/src/widgets/basic.dart';
//import 'package:flutter/src/widgets/container.dart';
import 'package:image_picker/image_picker.dart';
import 'package:video_player/video_player.dart';

And everything worked without errors. The application launched perfectly on the smartphone.

Of course, this is in my case, as applied to flutter image_picker_example. In your case, there will be something else instead of image_picker.

dan-gph
  • 16,301
  • 12
  • 61
  • 79
EdLan
  • 224
  • 2
  • 3
18

Deleting the .pub-cache folder solved my problem...


[my_expenses] flutter pub upgrade
Running "flutter pub upgrade" in my_expenses...                 
Could not find a file named "pubspec.yaml" in "/Users/charankumar/......../FlutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0".
pub upgrade failed (66)
exit code 66


$  rm -rf /Users/charankumar/......../FlutterSDK/flutter/.pub-cache/



[my_expenses] flutter pub get
Running "flutter pub get" in my_expenses...                        13.0s
exit code 0
genericUser
  • 4,417
  • 1
  • 28
  • 73
charan kumar
  • 335
  • 2
  • 11
3

I had similar problem when I tried to launch History of Everything Flutter app. Every time I opened it via Android Studio it showed a the "Could not find a file named “pubspec.yaml” in Flare-Flutter folder" error. After I tried those commands quoted below the problem disappear.

> git clone https://github.com/2d-inc/HistoryOfEverything.git cd
> HistoryOfEverything/app 
> git submodule init 
> git submodule update
> flutter run
Da Artagnan
  • 1,109
  • 3
  • 17
  • 26
3

Go to the .pub-cache folder which is located at the folder you installed flutter. In my case, it is C:\src\flutter\flutter.pub-cache and then delete it. After that run your project again, it will take some time but the problem was solved for me.

N. Joshi
  • 51
  • 3
1

None of the solutions here worked for me.

I realised it was due to the registry value for command prompt autorun being altered.

Solution steps (windows) Use RegEdit to set the registry for HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun.

The value should be blank, otherwise it messes with a script that flutter is using.

Solution for other systems not given but check that you are not modifying the auto startup for terminal or cmd.

H C O R
  • 11
  • 3
1

1.Just delete flutter from root folder.

2.Download from here [https://docs.flutter.dev/get-started/install/windows][1]

3.Set the path inside user variables under Edit environment variables.

4.Then just reset the path on android studio....

after that the problem will be gone.

Tanvir Ahmed
  • 564
  • 6
  • 13
1

If you use or the problem was caused by Visual Studio Code and you already ran flutter without problems before, try restarting your editor (Visual Studio Code).

If that doesn't work, in the Visual Studio Code terminal, run the command: flutter pub get. Then close Visual Studio Code. In your default terminal emulator, open and type: flutter pub get then restart your computer. Turn back on the computer and turn off your Wi-Fi internet or mobile data. Then, rotate the command you were trying to rotate again.

Note: I tried all the solutions here, but none of them worked, so I basically reported what I did to solve the problem.

thecoolmacdude
  • 2,036
  • 1
  • 23
  • 38
0

I had a similar problem (looking for pubspec.yaml in users directory) on Mac OS.

In the end, I removed flutter completely and reinstalled which seemed to fix the problem.

LeeHunter
  • 71
  • 1
  • 1
  • 7