如何解决 "Flutter build_runner FileException errorno = 3" 错误?

How do I solve "Flutter build_runner FileException errorno = 3" error?

你能帮我解决与 build_runner 相关的问题吗? 在 运行ning 命令“flutter packages pub 运行 build_runner watch --delete-conflicting-outputs”,我得到 FileException errorno = 3 error.

我怀疑这是一个 windows 问题。因为错误消息中生成的路径是小写的('c:\users\xxxx\git-dev\flutter\xxx\xxxx\xxxx*'),而实际路径('C:\Users\xxxx\git-dev\Flutter\xxx\xxxx\xxxx*')有几个大写字符。

[INFO] Generating build script...
[INFO] Generating build script completed, took 414ms

[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 11ms

[INFO] Waiting for all file watchers to be ready...

[SEVERE] Error from directory watcher for package:xxxxxx
If you see this consistently then it is recommended that you enable the polling file watcher with --use-polling-watcher.

You have hit a bug in build_runner

Please file an issue with reproduction steps at https://github.com/dart-enter code herelang/build/issues
     
FileSystemException: Directory listing failed, path =
'c:\users\xxxx\git-dev\flutter\xxx\xxxx\xxxx*' (OS Error: The system
cannot find the path specified., errno = 3)


Flutter doctor -v output is following:
[√] Flutter (Channel beta, 1.19.0-4.2.pre, on Microsoft Windows [Version 10.0.18363.900], locale en-IN)
• Flutter version 1.19.0-4.2.pre at C:\Users\xxxxxx\flutter
• Framework revision 9b9b543d92 (6 days ago), 2020-06-22 12:19:28 -0700
• Engine revision 9a28c3bcf4
• Dart version 2.9.0 (build 2.9.0-14.1.beta)

根据报错信息提示,我使用了“flutter pub 运行 build_runner watch --use-polling-watcher”命令。但是,我开始遇到另一种错误。

AssetNotFoundException: xxxx_xxxxx|.packages
package:build_runner_core/src/asset/file_based.dart 134:18 _fileForOrThrow.
dart:async _completeOnAsyncReturn
package:pool/pool.dart Pool.withResource
package:build_runner_core/src/asset/file_based.dart 133:26 _fileForOrThrow
package:build_runner_core/src/asset/file_based.dart 33:48 FileBasedAssetReader.readAsBytes
package:build_runner/src/generate/watch_impl.dart 326:52 WatchImpl._run.
package:build_runner/src/generate/watch_impl.dart WatchImpl._run.
package:build_runner/src/generate/watch_impl.dart 355:6 WatchImpl._run
package:build_runner/src/generate/watch_impl.dart 196:20 new WatchImpl
package:build_runner/src/generate/watch_impl.dart 127:5 _runWatch
package:build_runner/src/generate/watch_impl.dart 85:15 watch
dart:async _completeOnAsyncReturn
package:build_runner_core/src/generate/options.dart BuildOptions.create
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart TargetGraph.forPackageGraph
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart _packageBuildConfig
dart:async _completeOnAsyncReturn
package:build_config/src/build_config.dart BuildConfig.fromBuildConfigDir

我弄清楚了问题及其解决方案。

因为我在我的 flutter 应用程序中使用了“moor”包,所以我按照他们页面 (https://moor.simonbinder.eu/docs/using-sql/sql_ide/) 上的说明来设置 moor 分析器。

我在 VSCode json 设置中添加以下行后:

"dart.additionalAnalyzerFileExtensions": ["沼泽地"]

命令“flutter packages pub 运行 build_runner watch --delete-conflicting-outputs”停止工作。

删除 VSCode json 设置后,我可以再次 运行 build_runner 命令。