Skip to content

Fail fast when fly version upgrade can't write its install - #5698

Closed
alexleventer wants to merge 2 commits into
masterfrom
version-upgrade-agents
Closed

alexleventer wants to merge 2 commits into
masterfrom
version-upgrade-agents

Conversation

@alexleventer

Copy link
Copy Markdown
Collaborator

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 upgrade failed 30% of the time for agents vs 11% interactively. Telemetry has no error text, so the cause is inferred from a reproduction, not measured.

  • Explicit upgrade: in a read-only install, fly version upgrade downloaded the installer, which failed with mkdir … Permission denied and a bare Error: exit status 1.
  • Automatic upgrade: worse. A severely outdated or yanked flyctl tries to upgrade before every command. That failed the same way, and the command never ran (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.
  • Explicit upgrade: fly version upgrade checks 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.
  • Automatic upgrade: when the install isn't writable, the urgent pre-command upgrade is skipped. It prints "Update available X -> Y, but it can't be installed from here: …" and the command still runs. The background update is skipped silently, as it was already silent. The check runs only on paths that would upgrade.
  • Installer errors: "see the output above" is added only when the installer itself exited non-zero.

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:

Case master this branch
fly version upgrade installer fails, exit status 1 fails in <1s with the reason
severely outdated, fly orgs list in a terminal command fails notice, then the command runs

Tests: internal/update/writable_test.go; go test ./internal/... ./proxy/... passes; Windows build compiles.

Not changed (pre-existing): on Windows, a failed upgrade leaves flyctl.exe renamed to .old. Worth its own PR.

Related to: agent friendliness of the Fly CLI.


Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

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.
@alexleventer
alexleventer requested a review from a team as a code owner December 2, 2026 23:04
@alexleventer alexleventer added risk:medium Production risk (medium), set by foundations-pr-bot or a person narrow Changes the product itself (set by foundations-pr-bot or a person) labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

narrow Changes the product itself (set by foundations-pr-bot or a person) risk:medium Production risk (medium), set by foundations-pr-bot or a person

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant