could not load imported package and not generating file.
Hi, I got issue where i run build_runner but failed to generate any output. I mainly used it with stacked_cli, but failed to generating files.
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.5 24F74 darwin-arm64, locale en-ID) [2.2s]
• Flutter version 3.32.0 on channel stable at /Users/devin/fvm/versions/3.32.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision be698c48a6 (4 weeks ago), 2025-05-19 12:59:14 -0700
• Engine revision 1881800949
• Dart version 3.8.0
• DevTools version 2.45.1
dart run build_runner build --delete-conflicting-outputs
[WARNING] Could not load imported package "flag_builder" for definition "circle_flags:assetsToCache".
[WARNING] Could not load imported package "flag_builder" for definition "circle_flags:combineFlagFile".
[INFO] Generating build script completed, took 214ms
[INFO] Reading cached asset graph completed, took 692ms
[INFO] Checking for updates since last build completed, took 1.2s
[INFO] Running build completed, took 91ms
[INFO] Caching finalized dependency graph completed, took 290ms
[INFO] Succeeded after 396ms with 0 outputs (0 actions)
Let me know if you need more information
Did it work before? What changed?
Did it work before? What changed?
Yes it work as usual previously. I think we upgrade the flutter version and bump the package version. Let me check with previous versions.
also with this problem.
I am upgrading Flutter to latest now to see if this stops
the messages are still there but the output was alright.
I guess cleaning everything made the build work, not the Flutter version.
You are right, in new clean project its work as expected. it generated the new testService
here is the log:
Running dart run build_runner build --delete-conflicting-outputs ...
Generating the build script.
Reading the asset graph.
Checking for updates.
Updating the asset graph.
Building, incremental build.
0s stacked_generator:stackedRouterGenerator on 19 inputs; lib/app/app.dart
8s stacked_generator:stackedRouterGenerator on 19 inputs: 1 same; spent 7s analyzing, 1s resolving; lib/main.dart
9s stacked_generator:stackedRouterGenerator on 19 inputs: 18 skipped, 1 same; spent 7s analyzing, 1s resolving
0s stacked_generator:stackedLoggerGenerator on 38 inputs; lib/app/app.dart
0s stacked_generator:stackedLoggerGenerator on 38 inputs: 37 skipped, 1 no-op
0s stacked_generator:stackedLocatorGenerator on 76 inputs; lib/app/app.dart
0s stacked_generator:stackedLocatorGenerator on 76 inputs: 75 skipped, 1 output
0s stacked_generator:stackedFormGenerator on 152 inputs; lib/app/app.dart
0s stacked_generator:stackedFormGenerator on 152 inputs: 149 skipped, 3 no-op
0s stacked_generator:stackedDialogGenerator on 304 inputs; lib/app/app.dart
W stacked_generator:stackedRouterGenerator on lib/app/app.dart:
Your current `analyzer` version may not fully support your current SDK version.
Analyzer language version: 3.7.0
SDK language version: 3.8.0
Please update to the latest `analyzer` version (7.4.5) by running
`flutter packages upgrade`.
If you are not getting the latest version by running the above command, you
can try adding a constraint like the following to your pubspec to start
diagnosing why you can't get the latest version:
dev_dependencies:
analyzer: ^7.4.5
0s stacked_generator:stackedDialogGenerator on 304 inputs: 301 skipped, 1 same, 2 no-op
0s stacked_generator:stackedBottomsheetGenerator on 608 inputs; lib/app/app.dart
0s stacked_generator:stackedBottomsheetGenerator on 608 inputs: 605 skipped, 1 same, 2 no-op
0s mockito:mockBuilder on 320 inputs; test/golden/home_view_golden_test.bottomsheets.dart
1s mockito:mockBuilder on 320 inputs: 1 skipped, 1 no-op; test/golden/home_view_golden_test.dialogs.bottomsheets.dart
1s mockito:mockBuilder on 320 inputs: 315 skipped, 1 same, 4 no-op
Running the post build.
Writing the asset graph.
Built with build_runner in 11s; wrote 5 outputs.
I guess cleaning everything made the build work, not the Flutter version.
@jodinathan what cleaning do you perform?
I tried flutter clean and remove pubspec.lock but still cannot generate the files.
here is the log in the project:
Running dart run build_runner build --delete-conflicting-outputs ...
[INFO] Generating build script...
[WARNING] Could not load imported package "flag_builder" for definition "circle_flags:assetsToCache".
[WARNING] Could not load imported package "flag_builder" for definition "circle_flags:combineFlagFile".
[INFO] Generating build script completed, took 220ms
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 3.8s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 2.1s
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Deleting 81 declared outputs which already existed on disk.
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms
[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 1.8s elapsed, 0/16 actions completed.
[INFO] 3.3s elapsed, 0/16 actions completed.
[INFO] Generating SDK summary completed, took 4.1s
[INFO] 5.2s elapsed, 32/142 actions completed.
[INFO] 6.2s elapsed, 71/154 actions completed.
[INFO] 7.4s elapsed, 80/157 actions completed.
[INFO] 8.5s elapsed, 96/162 actions completed.
[INFO] 9.6s elapsed, 160/207 actions completed.
[INFO] 20.9s elapsed, 243/265 actions completed.
[INFO] 33.0s elapsed, 270/286 actions completed.
[INFO] 34.1s elapsed, 339/360 actions completed.
[INFO] 35.3s elapsed, 379/396 actions completed.
[INFO] 36.3s elapsed, 413/432 actions completed.
[INFO] 37.4s elapsed, 449/468 actions completed.
[INFO] 39.0s elapsed, 487/503 actions completed.
[INFO] 40.0s elapsed, 531/547 actions completed.
[INFO] 41.1s elapsed, 587/602 actions completed.
[INFO] 42.2s elapsed, 629/644 actions completed.
[INFO] 43.3s elapsed, 639/654 actions completed.
[INFO] 44.3s elapsed, 667/683 actions completed.
[INFO] 45.4s elapsed, 799/813 actions completed.
[INFO] 46.4s elapsed, 1047/1047 actions completed.
[INFO] 47.4s elapsed, 1693/1709 actions completed.
[INFO] 48.5s elapsed, 2162/2162 actions completed.
[INFO] Running build completed, took 48.8s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 375ms
[INFO] Succeeded after 49.3s with 456 outputs (3120 actions)
Command complete. ExitCode: 0
Running dart format . -l 80 ...
Formatted lib/l10n/arb/app_localizations.dart
Formatted 938 files (1 changed) in 2.64 seconds.
Command complete. ExitCode: 0
its succeed but app.locator.dart file from stacked is not generated.
Any solution?
@antoniomtnez we did not identify a specific issue, so it's hard to say if there is a solution :)
Are you using the same builder?
The logs on this issue are all from an old version of build_runner, the first thing I would suggest is to update packages as far as possible.
Hi @davidmorgan @antoniomtnez it seems previously the stacked_generator package is missing from my dev_dependencies. and I also update it to the latest version. Its working fine now. will close this thread
@davidmorgan I think with the latest version of build_runner what was previously a warning becomes a crash.
https://github.com/cedvdb/flutter_circle_flags/issues/45 The package circle_flags declares an incorrect builder.
This used to only be a warning like this:
Generating the build script.
W Could not load imported package "flag_builder" for definition "circle_flags:assetsToCache".
W Could not load imported package "flag_builder" for definition "circle_flags:combineFlagFile".
Now it is a crash:
E Error: Couldn't resolve the package 'flag_builder' in 'package:flag_builder/builders.dart'.
.dart_tool/build/entrypoint/build.dart:6:8: Error: Not found: 'package:flag_builder/builders.dart'
import 'package:flag_builder/builders.dart' as _i2;
^
.dart_tool/build/entrypoint/build.dart:15:40: Error: Undefined name 'assetsToCache'.
'circle_flags:assetsToCache': [_i2.assetsToCache],
^^^^^^^^^^^^^
.dart_tool/build/entrypoint/build.dart:16:42: Error: Undefined name 'combineFlagFile'.
'circle_flags:combineFlagFile': [_i2.combineFlagFile],
^^^^^^^^^^^^^^^
E Failed to compile build script. Check builder definitions and generated script .dart_tool/build/entrypoint/build.dart.
Thanks @xvrh. That looks like a different issue, so opened
https://github.com/dart-lang/build/issues/4239
I solved that problem by installing this package: stacked_generator