-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Pub global activate was broken when the VM flipped to Dart 2 by default. I'm working on fixing that. In the process, I stumbled into an important behavior that I believe used to work in the Dart 1 VM but does not any more. Let's say the user does this:
-
They run
pub get
. That downloads some packages and precompiles their binaries to snapshots so that they can be run faster. -
Later, they upgrade to a new version of the Dart SDK. That version has a VM with a newer snapshot version.
-
They
pub run
one of the executables. This tries to run the old snapshot generated in step 1 on the newer VM.
In Dart 1, at step 3, pub would catch an IsolateSpawnException and look for message "Wrong script snapshot version". If found, it would discard the old snapshot and generate a new one for the current VM, and then proceed merrily along its way.
In Dart 2, it looks like the VM hard aborts the entire process if you load an old snapshot. There's no way that pub can catch the error because it's not a thrown exception. The process just dies. At least I think that's what's going on.
Am I understanding the current behavior right? If so, how can pub detect an outdated snapshot and handle this case?
If we don't fix this soon, then the next time the VM revs the snapshot version, every user who has used pub run
(which is basically everyone, because of pub run test
) or pub global activate
since the switch to Dart 2 by default is going to blow up the next time they try to run one of those commands.