Drive upgrade when cli.new --agents finds an out-of-date Railway CLI#886
Merged
Conversation
Previously the --agents path skipped install entirely whenever a 'railway' binary was on PATH, leaving users stuck on whatever version they had — including pre-detection releases that emit no telemetry attribution. Now we read the existing binary's version, compare to the latest GitHub release, and prompt to upgrade in place when older. With --yes/--force or non-interactive stdin we auto-confirm. The upgrade writes back to the existing binary's directory so we don't shadow the user's install with a duplicate on PATH, skips the redundant "Install railway X to Y?" confirm, and skips the "restart your terminal" warning since PATH is already correct. Homebrew installs (/opt/homebrew/*, /usr/local/Cellar/*, and the Intel /usr/local/bin symlink) are detected and routed to 'brew upgrade railway' instead of being clobbered, then we fall through to agent setup with the existing CLI so the rest of cli.new --agents still works. Adds two helpers — extract_railway_version (handles 'railway 4.54.0', 'v4.54.0', '4.55.0-rc.1', empty/garbage) and version_lt (semver major.minor.patch comparison, pre-release suffixes stripped, returns false on any unparseable input so we never claim 'outdated' when we can't tell). Validated against 15 helper cases and 8 end-to-end decision scenarios. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes a UX gap where
curl cli.new --agentsskipped install entirely whenever arailwaybinary was on PATH, leaving users stuck on whatever version they had — including pre-detection releases that emit no telemetry attribution. Now the install script reads the existing binary's version, compares to the latest GitHub release, and prompts to upgrade in place when older.Behavior matrix
--yes/ non-interactive[Y/n], upgrade in place if acceptedbrew upgrade railway, run setup with currentThe upgrade writes back to the existing binary's directory (
dirname "$(command -v railway)") so we don't shadow the user's install with a duplicate on PATH, skips the redundantInstall railway X to Y?confirm, and skips the "restart your terminal" warning since PATH is already correct. Homebrew installs (/opt/homebrew/*,/usr/local/Cellar/*, and the Intel/usr/local/binsymlink to Cellar) are detected and routed tobrew upgrade railwayinstead of being clobbered.Helpers added
extract_railway_version— pullsX.Y.Z(with optional pre-release suffix) out ofrailway --versionoutput. Handlesrailway 4.54.0,v4.54.0,4.55.0-rc.1, plain4.54.0, empty, and garbage input.version_lt— semvermajor.minor.patchcomparison. Pre-release suffixes are stripped so4.55.0-rc.1compares equal to4.55.0(does not trigger a "downgrade" upgrade). Returnsfalseon any unparseable input so we never claim "outdated" when we can't tell.Test plan
Validated locally against:
extract_railway_versioncases (plain, version-only, with-v, rc suffix, dev suffix, empty, garbage)version_ltcases (lt by patch / minor / major, equal, greater, rc-vs-release, empty, garbage)All 23 cases pass.
bash -n install.shis clean.Background
Pairs with #885 (now merged). RFC: Agentic Loop Telemetry: MCP + CLI — the bigger the share of users on ≥ the caller-detection release, the smaller the NULL bucket in
fct_agentic_events. Driving upgrade throughcli.new --agentsis the primary way that adoption shifts week over week.🤖 Generated with Claude Code