Repository navigation
Fail fast when fly version upgrade can't write its install - #5698
Closed
alexleventer wants to merge 2 commits into
Closed
alexleventer wants to merge 2 commits into
alexleventer wants to merge 2 commits into
Conversation
Coding agents often run flyctl in a sandbox that can't write to the install directory. There, `fly version upgrade` ran the installer, which failed partway with a bare "exit status 1", and a severely outdated flyctl refused to run any command because its automatic upgrade failed the same way. Check that the binary's directory is writable first: the explicit upgrade says why it can't run and what to do instead, and the automatic upgrade is skipped so the command still runs.
Review findings: when an urgent update can't be installed, say so and proceed instead of skipping it silently; skip the write check under Homebrew, which writes elsewhere; treat a probe file that can't be removed as not writable; probe only where an upgrade would run; blame the installer's output only when the installer failed; broaden the advice beyond sandboxes.
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.
Change Summary
What and Why:
Coding agents often run flyctl in a sandbox that can't write to the install directory. Over 14 days of COMMAND_STATS,
fly version upgradefailed 30% of the time for agents vs 11% interactively. Telemetry has no error text, so the cause is inferred from a reproduction, not measured.fly version upgradedownloaded the installer, which failed withmkdir … Permission deniedand a bareError: exit status 1.failed to update, and the current version is severely out of date).How:
update.InstallWritable()creates and removes a probe file next to the running binary. It is skipped under Homebrew, which writes elsewhere and reports its own errors. A probe that can't be removed counts as not writable.fly version upgradechecks first and fails in under a second, saying why and what to do: in a sandbox, run it outside; otherwise fix the directory's ownership or reinstall.Unchanged: writable installs upgrade exactly as before. A real upgrade into a scratch install went 0.4.100 → 0.5.24.
Verified with a production build (version 0.4.100) in a read-only install dir:
fly version upgradeexit status 1fly orgs listin a terminalTests:
internal/update/writable_test.go;go test ./internal/... ./proxy/...passes; Windows build compiles.Not changed (pre-existing): on Windows, a failed upgrade leaves
flyctl.exerenamed to.old. Worth its own PR.Related to: agent friendliness of the Fly CLI.
Documentation