fix(install): don't require the GitHub API when RAILWAY_VERSION is pinned - #1031
Open
krushiraj wants to merge 1 commit into
Open
fix(install): don't require the GitHub API when RAILWAY_VERSION is pinned#1031krushiraj wants to merge 1 commit into
krushiraj wants to merge 1 commit into
Conversation
…nned install.sh fetched the latest release from the GitHub API unconditionally at the top of the script, and hard-failed on an empty response — before checking whether the caller had already pinned RAILWAY_VERSION, and before argument parsing. Three consequences: - `RAILWAY_VERSION=x.y.z bash install.sh` failed with "Failed to fetch latest version from GitHub" on a rate-limited API, even though the version was explicitly pinned and the fetched value was never used. - `--help` and `--uninstall` also failed, so removing an already-installed binary required a working network path to api.github.com. - `curl -s` (no `-f`) exits 0 on a 403 and prints the rate-limit JSON body, so `set -eu` never caught it; the grep simply found no tag_name. Move the lookup into resolve_version(), called after argument parsing and after the uninstall/help paths, and return early when RAILWAY_VERSION is already set. Pinning a version now makes an install independent of GitHub API rate limits, which is the point of supporting the variable. Also suggest pinning in the error message for the unpinned case. Fixes railwayapp#1030
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.
Fixes #1030.
Problem
install.shqueries the GitHub API for the latest release at line 411 — unconditionally, and with a hardexit 1on an empty result — before it checks whether the caller already pinnedRAILWAY_VERSION(line 420), and before argument parsing (line 451).Three consequences when the API is rate-limited or unreachable:
RAILWAY_VERSION=5.27.1 bash <(curl -fsSL railway.com/install.sh)errors out withFailed to fetch latest version from GitHub, even thoughDEFAULT_VERSIONis discarded on the very next line. This is the reported failure — it bites CI pipelines that pin a version specifically to be insulated from rate limits.--helpand--uninstallfail too. Both are handled well after line 411, so removing an already-installed binary requires a working network path toapi.github.com.curl -s(no-f) exits 0 on a 403 and prints the rate-limit JSON body, soset -eudoesn't catch it —grepjust finds notag_nameandDEFAULT_VERSIONends up empty.Fix
Move the lookup into
resolve_version(), return early whenRAILWAY_VERSIONis already set, and call it after argument parsing and after the uninstall/help blocks — immediately before the first use of$RAILWAY_VERSION.DEFAULT_VERSIONhad no other readers and is dropped. The unpinned failure path also now hints at pinning.Verification
bash -npasses. Stubbingcurlto return GitHub's 403 rate-limit body, onmastervs. this branch:masterRAILWAY_VERSION=5.27.1Failed to fetch latest version.../download/v5.27.1/...✅--helpFailed to fetch latest version--uninstallFailed to fetch latest versionShell-only change; no Rust code is touched.