Skip to content

fix: count a prebuilt CLI install as complete on rerun - #45

Merged
eseidel merged 1 commit into
mainfrom
fix-installed-check
Dec 1, 2026
Merged

eseidel merged 1 commit into
mainfrom
fix-installed-check

Conversation

@eseidel

@eseidel eseidel commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

Since shorebird#4529 (shorebirdtech/shorebird#4529), installing a release commit downloads a prebuilt CLI (bin/cache/shorebird + bin/cache/shorebird-cli.stamp) and never builds bin/cache/shorebird.snapshot. The installer's "already installed?" check still looked only for the snapshot. So every user who reruns the installer on a working install is told it is incomplete and to reinstall with --force, which deletes it and downloads it again. This repo's e2e "Rerun installer" step now fails on macOS, Linux and Windows, on every PR (e.g. https://github.com/shorebirdtech/install/actions/runs/46759839644).

Fix

Treat either marker as a complete install: shorebird.snapshot (non-release commit, compiled) or shorebird-cli.stamp (release commit, prebuilt; the launcher writes it only after the downloaded binary passes --version, third_party/flutter/bin/internal/shared.sh:162-169). Same change in install.sh and install.ps1.

Tested locally on macOS: ran install.sh twice into a temp HOME. The first run installed the prebuilt CLI; the second now prints "Shorebird is already installed".

What could go wrong

A real half-finished install that somehow has the stamp would now be called "already installed" (rerun suggests shorebird upgrade). The stamp is written last, after the binary has been verified, so that shouldn't happen.

Landing

Lands once approved and green. Unblocks #44's CI.

Screenshots

No visible change: CLI install script only.

🤖 Generated with Claude Code

Since shorebird#4529, an install of a release commit downloads a prebuilt
CLI (bin/cache/shorebird + shorebird-cli.stamp) and never builds
bin/cache/shorebird.snapshot, so rerunning the installer called a working
install incomplete and told users to --force reinstall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eseidel

eseidel commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial review (head 05ec568)

No blockers found. Checked against shorebird main: third_party/flutter/bin/internal/shared.sh (install_prebuilt_cli, prebuilt_is_current, shared::execute) and bin/shorebird.ps1 (Install-PrebuiltCli, Test-PrebuiltIsCurrent, Update-Shorebird).

Is the stamp a sound "complete" marker? Yes, on both platforms.

  • bash: shorebird-cli.stamp is written only after checksum match, unzip, mv into place, and "$PREBUILT_PATH" --version succeeding. A binary that fails --version is removed and no stamp is written.
  • Windows: Install-PrebuiltCli writes shorebird-cli.stamp (same name, so the ps1 check is right) only after & $prebuiltPath --version returns 0. Every failure path, including the catch, returns before Set-Content.
  • Both launchers keep one stamp at a time: the prebuilt path deletes shorebird.stamp, and the compile path deletes shorebird-cli.stamp. The snapshot itself isn't deleted on the prebuilt path, so the -o check still holds after a switch in either direction.
  • The installer's own --version step still has to exit 0 before INSTALL_COMPLETE/$installComplete is set. If it doesn't, the whole directory is removed. So a stamp left by a run that later failed doesn't survive into a rerun.

Any other code that assumes the snapshot? No. The failed-install cleanup in both scripts (cleanup_failed_install trap / finally) keys off the completion flag, not cache files. The two lines changed here were the only bin/cache references in either script.

Non-blocking:

  1. The description says the rerun step failed "on macOS and Linux". It failed on Windows too (run 46759839644, windows-latest: "A previous Shorebird install ... is incomplete."), which is expected since Windows x64 also gets the prebuilt. The ps1 half of the fix is needed, not just there for symmetry. All three jobs pass on the head commit.
  2. The check looks at the stamp alone, but the launcher's notion of current is stamp and binary ([[ -x "$PREBUILT_PATH" && -s ... ]], Test-Path $prebuiltPath). If something later deletes bin/cache/shorebird(.exe) (AV quarantine on Windows, a manual cache cleanup), the installer would say "already installed" while the CLI is missing. This heals itself: the next shorebird run sees the prebuilt isn't current and reinstalls or builds it. The old snapshot-only check had the same gap if the Flutter/Dart cache was missing. Optionally, also test for bin/cache/shorebird / shorebird.exe to match prebuilt_is_current. I wouldn't block on it.
  3. The stamp's revision isn't compared to HEAD. That's fine here: the question is "did an install ever finish", not "is it current", and shorebird upgrade is the suggested next step either way.

Risk is low: two condition changes, and both still fail closed (absent marker leads to "incomplete" plus a --force suggestion; nothing is deleted without --force).

@eseidel

eseidel commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. (1) Fixed the description: Windows failed too, so the ps1 change is needed. (2) I'm leaving out the extra binary check. If the binary is missing, the launcher's next shorebird run downloads it again, so the "already installed" message is still right in practice. (3) Agreed, no change.

@eseidel

eseidel commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

lgtm

@eseidel
eseidel merged commit 9b5161e into main Dec 1, 2026
3 checks passed
@eseidel
eseidel deleted the fix-installed-check branch December 1, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant