From b324287be7de56d329fe766cfd1b7f3e07e5588f Mon Sep 17 00:00:00 2001 From: Mihai Nueleanu Date: Fri, 30 Oct 2026 22:45:48 +0000 Subject: [PATCH] fix(installer): read the latest tag off the web redirect, not the API api.github.com/repos//releases/latest answers 200 with JSON and never redirects, so following it and looking for /tag/ in the effective URL always came up empty and every install died with 'could not work out the latest release tag'. The web URL does 302 to /releases/tag/ and is not rate limited; the JSON tag_name is kept as a fallback for API-only mirrors. --- install.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index a3a2517..258d6fc 100644 --- a/install.sh +++ b/install.sh @@ -52,12 +52,18 @@ need tar # ---- which version --------------------------------------------------------- if [ "$VERSION" = "latest" ]; then - # /releases/latest redirects to the newest non-prerelease tag; following it and - # reading the final URL avoids parsing JSON without jq - resolved=$(curl -fsSL -o /dev/null -w '%{url_effective}' "$API/repos/$REPO/releases/latest") \ - || die "could not reach GitHub to find the latest release" - tag=$(printf '%s' "$resolved" | sed -n 's|.*/tag/||p') - [ -n "$tag" ] || die "could not work out the latest release tag (got: $resolved)" + # api.github.com/repos//releases/latest answers 200 with JSON and does not + # redirect, so reading a /tag/ URL off the API call can never work. The web + # URL is the one that 302s to /releases/tag/, it needs no jq, and it is + # not rate limited like the API. The JSON stays as a fallback for a mirror + # that only serves the API side. + resolved=$(curl -fsSL -o /dev/null -w '%{url_effective}' "$DL/$REPO/releases/latest" 2>/dev/null || true) + tag=$(printf '%s\n' "$resolved" | sed -n 's|.*/tag/||p') + if [ -z "$tag" ]; then + json=$(curl -fsSL "$API/repos/$REPO/releases/latest" 2>/dev/null || true) + tag=$(printf '%s\n' "$json" | sed -n 's/^ *"tag_name": *"\([^"]*\)".*/\1/p' | head -1) + fi + [ -n "$tag" ] || die "could not work out the latest release tag (tried $DL/$REPO/releases/latest and $API/repos/$REPO/releases/latest); set KT_VERSION=vX.Y.Z to skip the lookup" VERSION="$tag" fi case "$VERSION" in