Everything works fine
Can't load Kernel binary: Invalid SDK hash.
Then app runs
Any way we can detect this? Recompile on first run after SDK upgrade?
Re-run pub global activate <package>
...it'd be nice if we even suggested this!
CC @jakemac53 @mit-mit @jonasfj @sigurdm
Is this new? I think we've always detected this... Maybe it just surfaced in the UI because of the refactoring of pub global run when we added the --enable-experiment.
My experience was:
$ dart --version
Dart SDK version: 2.9.0-21.0.dev (dev) (Wed Jul 8 10:54:08 2020 +0200) on "linux_x64"
$ mono_repo
Can't load Kernel binary: Invalid kernel binary format version.
Precompiling executable... (1.6s)
Precompiled mono_repo:mono_repo.
Manage multiple packages in one source repository
Looking at PUB_CACHE/bin/mono_repo I find:
#!/usr/bin/env sh
# This file was created by pub v2.8.1.
# Package: mono_repo
# Version: 2.3.0
# Executable: mono_repo
# Script: mono_repo
dart "/home/jonasfj/.pub-cache/global_packages/mono_repo/bin/mono_repo.dart.snapshot.dart2" "$@"
# The VM exits with code 253 if the snapshot version is out-of-date.
# If it is, we need to delete it and run "pub global" manually.
exit_code=$?
if [ $exit_code != 253 ]; then
exit $exit_code
fi
pub global run mono_repo:mono_repo "$@"
So the problem is that wrapper scripts for the old versions tries to invoke the old snapshot.
We are no longer updating this snapshot, because we figured it prudent to include the SDK version in the filename of the snapshot. I believe we came to this conclusion after realizing that the behavior of the Dart VM was undefined when given old snapshots (that might also have been fixed using a hash of the SDK in the snapshot).
Running pub global activate mono_repo is certainly a work around. We could also stop putting the SDK version number in the snapshot filename, that way this would only happen once. Or maybe we should rewrite old bin-stubs the first time pub global run is invoked.
@sigurdm, the stuff we just landed to deprecate the pub command in favor of dart pub will also affect these bin-stubs.
@kevmoo @sigurdm hi! I think I am experiencing this error after an upgrade of the Dart SDK (I think from 2.4.0 to 2.9.3). How to reproduce my issue is complicated for me to explain.
I'd like to understand what's the actual underlying problem and if with the latest upgrade to stable Dart 2.9.3 is solved (and maybe It's just a caching problem on my end of some sort).
I'm sure I'm missing something but I can't find an actionable solution or explaination about this.
I would love a bit more context so I can fix my broken builds :-)
If this issue is not relevant to my issue (see my mention above), I'd love to be pointed to the right place.
Thanks
@apiraino 鈥撀爐he fix went in
This PR: https://github.com/dart-lang/pub/pull/2610
Which corresponds to this commit: https://github.com/dart-lang/pub/commit/cf9795f3bb209504c349e20501f0b4b8ae31530c
Which is NOT in any Dart SDK YET.
How is your build broken? Are you using a globally activated binary?
How is your build broken? Are you using a globally activated binary?
thanks for the reply and the link to the PR. I am not sure I'm running a global activated binary (in fact I am using pre-built flutter engine binaries), but since I'm experiencing similar symptoms I was trying to figure out what the actual cause is for this error.
My blind guess is that the Flutter engine can be compiled only against certain versions of the Dart SDK, even in the same stable channel. Makes sense?
@apiraino
When the VM prints an error like Can't load Kernel binary: Invalid SDK hash. it's because the snapshot loaded is incompatible with the Dart VM running the snapshot.
As I understand it, there are different kinds of snapshots, but there is no promises that the snapshot format won't change between Dart versions, so the snapshots typically embed the Dart SDK hash that generated them, and the VM will generally refuse to run snapshots not generated with the same version of the SDK.
I fixed this problem by deleting the "flutter" folder and reinstalling it completely from the official site.
I hope it can help you
I was able to not reinstall flutter to get this to working again. I used:
flutter upgrade
flutter clean
flutter pub get
pod repo update
flutter build ios
Not sure if all those are needed, but just wanted to share. also this seemed related and where I got some of this:
What is the package do we need to run globally .?
Most helpful comment
@apiraino
When the VM prints an error like
Can't load Kernel binary: Invalid SDK hash.it's because the snapshot loaded is incompatible with the Dart VM running the snapshot.As I understand it, there are different kinds of snapshots, but there is no promises that the snapshot format won't change between Dart versions, so the snapshots typically embed the Dart SDK hash that generated them, and the VM will generally refuse to run snapshots not generated with the same version of the SDK.