feat: support Linux ARM64 by invalidating bundled x64 stamps - #1
Merged
Conversation
added 2 commits
July 5, 2026 12:33
Flutter's official Linux tarball bundles an x86-64 dart-sdk under
bin/cache/dart-sdk/ plus matching engine-dart-sdk.stamp and
flutter_tools.stamp. On non-x86_64 Linux hosts (aarch64, riscv64) the
bundled dart binary cannot execute, and the first `flutter` invocation
fails with:
.../bin/internal/shared.sh: line 273:
.../bin/cache/dart-sdk/bin/dart: cannot execute binary file: Exec format error
Because both shipped stamps match on first run, Flutter's self-heal
(update_dart_sdk.sh) is never reached - it is only invoked when
flutter_tools.stamp is invalid - so the wrong-arch dart binary is never
replaced.
Fix: after extraction, on non-x86_64 Linux hosts delete both
engine-dart-sdk.stamp and flutter_tools.stamp so update_dart_sdk.sh
runs on first invocation, detects the host arch, and fetches the
matching dart-sdk (e.g. dart-sdk-linux-arm64.zip).
The stamp-invalidation logic is extracted into a standalone function
(invalidate_bundled_stamps_for_non_x64_linux) so it can be unit-tested
in isolation. A bats suite (test/install.bats) guards the regression on
both x86_64 (stamps preserved) and aarch64 (stamps removed), and CI
runs the suite on ubuntu-24.04 and ubuntu-24.04-arm runners.
Drive-by fix: bin/utils.sh line 3 used ${VAR:=default} without a
leading ':' no-op, which tried to execute the URL as a command and
returned exit 127 under `set -e`. Fixed to the standard
`: "${VAR:=default}"` idiom.
See docs/adr/adr001-linux-arm64-support.md for the full diagnosis and
rationale, and the README troubleshooting section for user-facing
context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merging the upstream-bound feature branch into the fork's default branch so it's available here regardless of when the upstream PR (asdf-community#58 on asdf-community/asdf-flutter) is merged.
See that PR for full context, or the ADR at `docs/adr/adr001-linux-arm64-support.md` for the diagnosis and rationale.
Problem
On Linux `aarch64` hosts, `asdf install flutter ` completes successfully but the first `flutter` invocation fails with:
```
.../bin/internal/shared.sh: line 273:
.../bin/cache/dart-sdk/bin/dart: cannot execute binary file: Exec format error
```
Root cause
Flutter's Linux tarball bundles an x86-64 dart-sdk plus matching `engine-dart-sdk.stamp` and `flutter_tools.stamp`. Because the stamps match on first run, Flutter's self-heal (`update_dart_sdk.sh`, the script that detects host arch and fetches the matching dart-sdk) is never reached. The wrong-arch dart binary stays in place.
`releases_linux.json` exposes no `dart_sdk_arch` field (all 719 entries are `x64`), so the macOS-style archive filtering can't be reused on Linux.
Fix
After extraction, on non-`x86_64` Linux hosts delete both stamps so `update_dart_sdk.sh` runs on first invocation, detects the host arch via `uname -m`, and fetches the matching dart-sdk (e.g. `dart-sdk-linux-arm64.zip`).
The stamp-invalidation logic is extracted into a standalone function (`invalidate_bundled_stamps_for_non_x64_linux`) so it can be unit-tested in isolation. Architecture detection is delegated to Flutter's own `update_dart_sdk.sh`, which already handles `aarch64` and `riscv64` correctly.
Changes
Verification