gpt4 book ai didi

Flutter - 运行 flutter 失败,找不到名为 "pubspec.yaml"的文件,更新 -(操作系统错误 : Access is denied.,errno = 5)

转载 作者:IT王子 更新时间:2023-10-29 07:06:16 26 4
gpt4 key购买 nike

我刚刚解决了所有必要的依赖关系。

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 packages upgrade -v 时尝试使用 verbose 并得到了这个

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 要求我在使用 verbose 时在空目录中创建一个新应用

输出:

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)

最佳答案

不要将 .packages 从一台机器复制到另一台机器。 (如果使用 git,它应该在 .gitignore 中。)

相反,在 mac 上运行 flutter packages get,它将重新创建 .packages

(也不要复制 .flutter-plugins。)

  1. 删除.packages
  2. 删除pubspec.lock
  3. 运行如下图所示的命令

Run below command shown in image

关于Flutter - 运行 flutter 失败,找不到名为 "pubspec.yaml"的文件,更新 -(操作系统错误 : Access is denied.,errno = 5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52202923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com