Build: After modifying the name in the pubspec. yaml file, running [flutter packages pub run build_runner build] will cause errors

Created on 18 Dec 2018  Â·  2Comments  Â·  Source: dart-lang/build

In the flutter project. flutter issues
When I changed the project name, there was an error in executing the command to generate the JSON file, Even if I run the flutter clean command, this error will still occur.
If I change the original project name again, I can generate JSON related files normally.
I have the same problem with both Win10 and macOs.

pubspec.yaml

dependencies:
flutter:
sdk: flutter
json_annotation: ^2.0.0

dev_dependencies:
build_runner: ^1.0.0
json_serializable: ^2.0.0

flutter doctor -v

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
• Flutter version 1.0.0 at /Users/jianhan/resource/develop/sdk/flutter
• Framework revision 5391447fae (3 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /Users/jianhan/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/jianhan/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 29.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.4)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 31.1.3
• Dart plugin version 182.5124

[!] VS Code (version 1.27.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
• MI 4LTE • 679f5033 • android-arm • Android 6.0.1 (API 23)
• iPhone 8 Plus • 6083BB32-E050-4767-88D4-E3E7FB8B2E67 • ios • iOS 12.1 (simulator)

! Doctor found issues in 1 category.

flutter --verbose packages pub run build_runner build

[ +33 ms] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +33 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git rev-parse --abbrev-ref HEAD
[ +10 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ ] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git ls-remote --get-url origin
[ +11 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +2 ms] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git log -n 1 --pretty=format:%H
[ +15 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ ] 5391447fae6209bb21a89e6a5a6583cac1af9b4b
[ ] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git log -n 1 --pretty=format:%ar
[ +13 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[ ] 3 weeks ago
[ ] executing: [/Users/jianhan/resource/develop/sdk/flutter/] git describe --match v..* --first-parent --long --tags
[ +15 ms] Exit code 0 from: git describe --match v..* --first-parent --long --tags
[ ] v1.0.0-0-g5391447fa
[ +143 ms] Using /Users/jianhan/resource/develop/sdk/flutter/.pub-cache for the pub cache.
[ +3 ms] executing: /Users/jianhan/resource/develop/sdk/flutter/bin/cache/dart-sdk/bin/pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 309ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies.
[INFO] Cleaning up outputs from previous builds....

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues

InvalidOutputException: flutter_study|lib/StatisticsSparePartDTO.g.dart
Should not delete assets outside of flutter_temp
package:build_runner_core/src/asset/file_based.dart 98:7 FileBasedAssetWriter.delete
package:build_runner_core/src/generate/build_definition.dart 270:38 _Loader._cleanupOldOutputs..
dart:async Future.wait
package:build_runner_core/src/generate/build_definition.dart 266:20 _Loader._cleanupOldOutputs.
package:build_runner_core/src/logging/logging.dart 25:30 logTimedAsync
package:build_runner_core/src/generate/build_definition.dart 263:11 _Loader._cleanupOldOutputs
package:build_runner_core/src/generate/build_definition.dart 224:13 _Loader._tryReadCachedAssetGraph.
package:build_runner_core/src/logging/logging.dart 25:30 logTimedAsync
package:build_runner_core/src/generate/build_definition.dart 213:12 _Loader._tryReadCachedAssetGraph
package:build_runner_core/src/generate/build_definition.dart 79:28 _Loader.prepareWorkspace
package:build_runner_core/src/generate/build_definition.dart 64:50 BuildDefinition.prepareWorkspace
package:build_runner_core/src/generate/build_impl.dart 105:49 BuildImpl.create
package:build_runner_core/src/generate/build_runner.dart 31:37 BuildRunner.create
package:build_runner/src/generate/build.dart 105:35 build
package:build_runner/src/entrypoint/build.dart 28:24 BuildCommand.run
package:args/command_runner.dart 196:27 CommandRunner.runCommand
package:args/command_runner.dart 111:29 CommandRunner.run.
dart:async new Future.sync
package:args/command_runner.dart 111:11 CommandRunner.run
package:build_runner/src/entrypoint/run.dart 23:31 run
.dart_tool/build/entrypoint/build.dart 19:22 main

[+1908 ms] "flutter pub" took 1,998ms.
pub finished with exit code 1

0 throwToolExit (package:flutter_tools/src/base/common.dart:26:3)

1 pubInteractively (package:flutter_tools/src/dart/pub.dart:186:5)

2 PackagesPassthroughCommand.runCommand (package:flutter_tools/src/commands/packages.dart:148:11)

3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:401:18)

4 _asyncThenWrapperHelper. (dart:async/runtime/libasync_patch.dart:77:64)

5 _rootRunUnary (dart:async/zone.dart:1132:38)

6 _CustomZone.runUnary (dart:async/zone.dart:1029:19)

7 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)

8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)

9 Future._propagateToListeners (dart:async/future_impl.dart:671:32)

10 Future._complete (dart:async/future_impl.dart:476:7)

11 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)

12 _AsyncAwaitCompleter.complete. (dart:async/runtime/libasync_patch.dart:33:20)

13 _rootRun (dart:async/zone.dart:1124:13)

14 _CustomZone.run (dart:async/zone.dart:1021:19)

15 _CustomZone.bindCallback. (dart:async/zone.dart:947:23)

16 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)

17 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

18 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)

19 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172

Most helpful comment

This looks like something we should handle more smoothly.

For the record, flutter clean would not be expected to help here. flutter packages pub run build_runner clean should fix the situation - but also hopefully shouldn't be necessary.

All 2 comments

This looks like something we should handle more smoothly.

For the record, flutter clean would not be expected to help here. flutter packages pub run build_runner clean should fix the situation - but also hopefully shouldn't be necessary.

@natebosch Your method is useful to me, thanks.

Was this page helpful?
0 / 5 - 0 ratings