checkBinstubSdk function
Returns the mismatch when fdb runs from a global activation and
PUB_CACHE/bin/fdb hardcodes another SDK's snapshot; otherwise null.
Reads files only; never throws.
Implementation
BinstubSdkMismatch? checkBinstubSdk(BinstubSdkCheckInput input) {
try {
final pubCache = input.pubCacheDir;
final running = input.runningDartVersion;
if (input.isWindows || pubCache == null || running.isEmpty) return null;
if (!_isUnder(input.scriptPath, '$pubCache/global_packages/fdb/')) return null;
final lines = File('$pubCache/bin/fdb').readAsLinesSync();
if (!lines.any((l) => l.trim() == '# Package: fdb')) return null;
if (lines.any((l) => l.trim() == launcherMarker)) return null;
final activated = lines.map(_snapshotRef.firstMatch).nonNulls.firstOrNull?.group(1);
if (activated == null || activated == running) return null;
return (activated: activated, running: running);
} catch (_) {
return null; // Missing/unreadable launcher — nothing to report.
}
}