Flutter - Running flutter fails, Could not find a file named "pubspec.yaml", Update - (OS Error: Access is denied. , errno = 5)

Viewed 11637

I just solved all the necessary dependencies.

Building flutter tool...
Running pub upgrade...
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.228], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Community Edition (version 2018.2)
[√] Connected devices (1 available)

Now when I try running the flutter app on Android Studio I get this.

A:\Project\flutter_app>flutter run
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in flutter_app...
Could not find a file named "pubspec.yaml" in "C:\".
pub get failed (66)

Does anyone know what to do to resolve this issue?

[Update 2 hours later]

I deleted flutter and reinstalled in *C:\flutter* using the git repo https://github.com/flutter/flutter.git

Now the error I am getting is this

A:\Project\flutter_app>flutter run
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in flutter_app...
Cannot open file, path = '.\pubspec.lock' (OS Error: Access is denied.
, errno = 5)
pub get failed (66)

Update: I tried using verbose when running flutter packages upgrade -v and got this

C:\flutter\flutter_app>flutter packages upgrade -v
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
[  +31 ms] executing: [C:\Users\Nick\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +76 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] origin/beta
[        ] executing: [C:\Users\Nick\flutter\] git rev-parse --abbrev-ref HEAD
[  +45 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] beta
[        ] executing: [C:\Users\Nick\flutter\] git ls-remote --get-url origin
[  +38 ms] Exit code 0 from: git ls-remote --get-url origin
[   +9 ms] https://github.com/flutter/flutter.git
[        ] executing: [C:\Users\Nick\flutter\] git log -n 1 --pretty=format:%H
[  +38 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[   +1 ms] 3b309bda072a6b326e8aa4591a5836af600923ce
[   +7 ms] executing: [C:\Users\Nick\flutter\] git log -n 1 --pretty=format:%ar
[  +37 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[   +1 ms] 9 days ago
[        ] executing: [C:\Users\Nick\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +41 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v0.7.3-0-g3b309bda0
[ +170 ms] Running "flutter packages upgrade" in flutter_app...
[  +10 ms] executing: [C:\flutter\flutter_app\] C:\Users\Nick\flutter\bin\cache\dart-sdk\bin\pub.bat --verbosity=warning --verbose upgrade --no-precompile
[+16555 ms] Cannot open file, path = '.\pubspec.lock' (OS Error: Access is denied.
[   +1 ms] , errno = 5)
[  +46 ms] Running "flutter packages upgrade" in flutter_app... (completed)
[  +15 ms] "flutter upgrade" took 16,687ms.
pub upgrade failed (66)

#0      throwToolExit (package:flutter_tools/src/base/common.dart:26:3)
#1      pub (package:flutter_tools/src/dart/pub.dart:170:5)
<asynchronous suspension>
#2      pubGet (package:flutter_tools/src/dart/pub.dart:104:13)
<asynchronous suspension>
#3      PackagesGetCommand._runPubGet (package:flutter_tools/src/commands/packages.dart:59:11)
<asynchronous suspension>
#4      PackagesGetCommand.runCommand (package:flutter_tools/src/commands/packages.dart:82:11)
<asynchronous suspension>
#5      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:356:18)
#6      _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
#7      _rootRunUnary (dart:async/zone.dart:1132:38)
#8      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#9      _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#10     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#11     Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#12     Future._complete (dart:async/future_impl.dart:476:7)
#13     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#14     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
#15     _rootRun (dart:async/zone.dart:1124:13)
#16     _CustomZone.run (dart:async/zone.dart:1021:19)
#17     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#18     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#20     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#21     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5) 

Created GitHub issue https://github.com/flutter/flutter/issues/21495

Update: Not much has improved

@pskink asked me to create a new app in an empty directory while using verbose

Output:

C:\flutter>flutter create flutter_app -v
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Multiple output directories specified.
Try moving -v to be immediately following create

#0      throwToolExit (package:flutter_tools/src/base/common.dart:26:3)
#1      CreateCommand.runCommand (package:flutter_tools/src/commands/create.dart:106:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:356:18)
#3      _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
#4      _rootRunUnary (dart:async/zone.dart:1132:38)
#5      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#6      _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8      Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9      Future._complete (dart:async/future_impl.dart:476:7)
#10     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#11     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
#12     _rootRun (dart:async/zone.dart:1124:13)
#13     _CustomZone.run (dart:async/zone.dart:1021:19)
#14     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#15     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#16     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#17     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#18     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
6 Answers

Don't copy .packages over from one machine to another. (It should be in .gitignore if using git.)

Instead, run flutter packages get on the mac, and it will recreate .packages.

(Don't copy .flutter-plugins either.)

  1. Delete .packages
  2. Delete pubspec.lock
  3. Run below command shown in image

Run below command shown in image

I assume this is caused by and outdated Git client.

Please ensure you only have one Git client in your PATH and that it is in a recent version.

I found a temporary solution. When I run the same command on Power Shell as an administrator it doesn't show any error.

PS C:\flutter\flutter_app> flutter packages get
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in C:\...                    16.1s
PS C:\flutter\flutter_app> flutter packages upgrade
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages upgrade" in C:\...                86.9s

kill dart.exe, try run

if still error, after kill, reopen android studio as admin

Delete app/.packages file from your project and use flutter upgrade to get packages again.

This problem was related to my antivirus program. It worked when I uninstalled the block. Maybe it will help. I wish everybody good work

Related