From 4cf673f3b67badf297fdc5473ab43ad907b879db Mon Sep 17 00:00:00 2001 From: ChuckBuilds Date: Sat, 15 Aug 2026 21:04:29 -0400 Subject: [PATCH] fix(pixlet): resolve the release tag correctly when downloading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starlark apps render through the pixlet binary, and the installer that fetches it silently produced nothing, so every app failed with "Pixlet not available - Starlark apps will not work". Two compounding defects: The version lookup parsed the wrong token. GitHub returns the release JSON on a single line, so `grep '"tag_name"'` matches the whole document and the greedy `sed 's/.*"([^"]+)".*/\1/'` captures the LAST quoted string in it. That resolved to "mentions_count", giving a download URL for a release that does not exist. The `[ -z "$PIXLET_VERSION" ]` fallback never fired, because the value was not empty -- just wrong. And `curl -L -o` without `-f` writes a 404 body to the file and exits 0, so the download was reported as successful and the first sign of trouble was tar complaining "not in gzip format" about a page of HTML: → Downloading linux-arm64... Extracting... gzip: stdin: not in gzip format ✗ Failed to extract archive: .../pixlet_mentions_count_linux-arm64.tar.gz Download complete: 0/1 succeeded Now the tag field is matched directly and the value taken from it, and the result is checked for a version shape rather than merely being non-empty -- a wrong-but-non-empty value is exactly what made this silent. curl gets -f so an HTTP error is a failure, and the archive is gzip-tested before extraction, since a proxy can return 200 with an error page. Verified on an arm64 rig: v0.53.1 resolved, 1/1 downloaded, the binary runs, and the plugin's own detection finds it at bin/pixlet/pixlet-linux-arm64. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5 --- scripts/download_pixlet.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/download_pixlet.sh b/scripts/download_pixlet.sh index 53a38d22f..401c3ccd7 100755 --- a/scripts/download_pixlet.sh +++ b/scripts/download_pixlet.sh @@ -24,9 +24,20 @@ echo "========================================" # Auto-detect latest version if needed if [ "$PIXLET_VERSION" = "latest" ]; then echo "Detecting latest version..." - PIXLET_VERSION=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') - if [ -z "$PIXLET_VERSION" ]; then - echo "Failed to detect latest version, using fallback" + # GitHub returns this JSON on a single line, so `grep '"tag_name"'` + # matches the whole document and a greedy `sed 's/.*"([^"]+)".*/\1/'` + # captures the LAST quoted token in it rather than the tag. That resolved + # to "mentions_count", which built a download URL for a release that does + # not exist. Match the field itself and take the value after it. + PIXLET_VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ + | grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' \ + | head -n1 \ + | sed -E 's/.*:[[:space:]]*"([^"]*)".*/\1/') + + # A wrong-but-non-empty value is what made the old bug silent, so check + # the shape rather than just that something came back. + if ! printf '%s' "$PIXLET_VERSION" | grep -qE '^v?[0-9]+\.[0-9]+'; then + echo "Could not detect the latest version (got: '${PIXLET_VERSION:-}'), using fallback" PIXLET_VERSION="v0.50.2" fi fi @@ -67,8 +78,19 @@ download_binary() { temp_dir=$(mktemp -d -p "$PROJECT_ROOT" -t pixlet_download.XXXXXXXXXX) local temp_file="$temp_dir/$archive_name" - if ! curl -L -o "$temp_file" "$url" 2>/dev/null; then - echo "✗ Failed to download $arch" + # -f so an HTTP error is a failure. Without it curl writes the 404 body + # to the file and exits 0, and the first sign of trouble is tar saying + # "not in gzip format" about what is actually a page of HTML. + if ! curl -fL -o "$temp_file" "$url" 2>/dev/null; then + echo "✗ Failed to download $arch from $url" + rm -rf "$temp_dir" + return 1 + fi + + # Belt and braces: a mirror or proxy can return 200 with an error page. + if ! gzip -t "$temp_file" 2>/dev/null; then + echo "✗ Downloaded file is not a gzip archive: $url" + echo " (first bytes: $(head -c 60 "$temp_file" | tr -d '\0' | tr '\n' ' '))" rm -rf "$temp_dir" return 1 fi