Flutter-运行Flutter失败,找不到名为“ pubspec.yaml”的文件,更新-(操作系统错误:访问被拒绝。,errno = 5)

时间:2018-09-06 11:19:04

标签: flutter flutter-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)

现在,当我尝试在Android Studio上运行flutter应用程序时,就会明白这一点。

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)

有人知道该怎么做吗?

[ 2小时后更新]

我删除了flutter并使用git repo重新安装在* C:\ flutter *中 https://github.com/flutter/flutter.git

现在我得到的错误是这个

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)

更新:我在运行 flutter软件包升级-v 时尝试使用详细信息,并得到了

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) 

创建了GitHub问题https://github.com/flutter/flutter/issues/21495

更新:没什么改善

@pskink要求我在使用详细命令时在空目录中创建一个新应用

输出:

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 个答案:

答案 0 :(得分:0)

我认为这是由过时的Git客户端引起的。

请确保您的PATH中只有一个Git客户端,并且该客户端是最新版本。

答案 1 :(得分:0)

我找到了一个临时解决方案。当我以管理员身份在Power Shell上运行相同的命令时,它没有显示任何错误。

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

答案 2 :(得分:0)

杀死dart.exe,尝试运行

如果仍然出错, 杀死后,以管理员身份重新打开android studio

答案 3 :(得分:0)

从项目中删除app / .packages文件,并使用flutter升级再次获取软件包。

答案 4 :(得分:0)

请勿将.packages从一台计算机复制到另一台计算机。 (如果使用git,则应位于.gitignore中。)

相反,在Mac上运行flutter程序包,它将重新创建.packages

(请勿复制.flutter-plugins either。)

  1. 删除.packages
  2. 删除pubspec.lock
  3. 在图像中显示的以下命令下运行

Run below command shown in image

答案 5 :(得分:0)

这个问题与我的防病毒程序有关。当我卸载块时它起作用了。也许它会有所帮助。祝大家工作顺利