build_runner fails to start up due to missing command `frontend_server.dart.snapshot`
- The Dart SDK Version (Dart SDK version: 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "macos_x64") and
- What package(s) from this repo you are using, and the version (i.e.
build_runner 0.7.12)-
If you are not sure, try checking your
pubspec.lockfile.
build_runner: dependency: "direct dev" description: name: build_runner sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b" url: "https://pub.dev" source: hosted version: "2.4.6" build_runner_core: dependency: transitive description: name: build_runner_core sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185 url: "https://pub.dev" source: hosted version: "7.2.11" -
If you are not sure, try checking your
See the attached minimal crashing example. I have tried to run dart run build_runner run or watch or clean, inside the devcontainer in 3.7.2 and 3.5.0, and on my host after i installed and zapped dart off of it.
Additionally i tried running build_runner with multiple versions of build_runner(2.3.3, 2.4.0, 2.4.15) and json_serialisable (6.9.4, 6.8.0).
All of these runs resulted in the same error Precompiling build script......Could not find a command named "/usr/local/Cellar/dart-sdk/3.7.2/libexec/bin/snapshots/frontend_server.dart.snapshot"..
dart run build_runner watch
Building package executable... (5.6s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 438ms
[INFO] Precompiling build script......Could not find a command named "/usr/local/Cellar/dart-sdk/3.7.2/libexec/bin/snapshots/frontend_server.dart.snapshot".
Usage: dart <command|dart-file> [arguments]
Global options:
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable analytics.
--disable-analytics Disable analytics.
--suppress-analytics Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help Print this usage information.
Available commands:
analyze Analyze Dart code in a directory.
compile Compile Dart to various formats.
create Create a new Dart project.
devtools Open DevTools (optionally connecting to an existing application).
doc Generate API documentation for Dart projects.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
info Show diagnostic information about the installed tooling.
pub Work with packages.
run Run a Dart program.
test Run tests for a project.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
[INFO] Precompiling build script... completed, took 155ms
[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
I didnt use dart in a long time and had to pickup an old project, but i know that i left the project on my drive in a working state. Therefor i believe that i didnt misconfigure the builder
I think this relates to the SDK version being too new for the build_runner version.
Could you try dart pub upgrade and see what's on old versions?
Also do you have any dependency_overrides?
@davidmorgan Yes i did an upgrade with no change (See pubspec.yaml). @jakemac53 Not that i know of. I only used JsonSerialisable and JsonKey in the code. The rest is in the example i have attached
If I run dart pub upgrade on your example it upgrades build_runner
> build_runner 2.4.15 (was 2.4.6)
which should be exactly the fix. What does it output when you run it?
@davidmorgan I faced the same issue and I used this command
dart pub upgrade
And I get this error
Built build_runner:build_runner.
Unhandled exception:
Bad state: Unable to generate package graph, no `/.pub-cache/hosted/pub.dev/js-0.7.2/pubspec.yaml` found.
@MuhammadEhsanMirzaei I can't tell what you're doing from that snippet, please add more information and I'll see if I can help.
@Hu1buerger I faced the same issue, and switching to Flutter version 3.24.0 along with build_runner 2.4.11 resolved it for me. @davidmorgan I tried running dart pub upgrade, but I still got the same output — so unfortunately, it didn’t solve the issue.
@MuhammadEhsanMirzaei yep me too. Just wondering why a working project failed to build and the error could be more descriptive.
Due to the error I just had to blindly pull in some new updates and hope....
Importing the dependency below resolves the issue from my end.
frontend_server_client: ^4.0.0
@hu1buerger This worked for me https://github.com/dart-lang/build/issues/3733#issuecomment-2600741026