Skip to content

install.sh fails: tag_name parsing breaks on compact GitHub API JSON #411

Closed

Description

@ravshansbox

The version-detection line in scripts/install.sh assumes pretty-printed (multi-line) JSON:

VERSION=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)

GitHub's API now returns compact single-line JSON for /releases/latest. With no newlines, grep matches the whole blob and cut -d'"' -f4 returns the url field instead of the tag, so VERSION becomes e.g.:

https://api.github.com/repos/1jehuang/jcode/releases/342601544

The download URLs are then invalid, both curl downloads fail silently (2>/dev/null), and the script falls through to build-from-source (needs git+cargo) or errors out.

Reproduction

curl -fsSL "https://api.github.com/repos/1jehuang/jcode/releases/latest" | grep '"tag_name"' | cut -d'"' -f4
# prints a URL, not v0.31.2

Fix

Keep it dependency-free (no jq) but make it newline-agnostic:

VERSION=$(curl -fsSL ".../releases/latest" | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4)

grep -o extracts only the "tag_name":"..." substring, working for both compact and pretty-printed JSON.

Activity

  1. ravshansbox commented on Jun 28, 2026

    @ravshansbox
    Author

    Verified the root cause and the proposed fix.

    GitHub's /releases/latest API non-deterministically returns compact (single-line) vs pretty-printed (multi-line) JSON. The current parser only handles the pretty-printed case, which is why the failure is intermittent.

    Tested both parsers against pretty and forced-compact responses:

    Format OLD parser NEW parser
    pretty (multi-line) ✅ v0.31.2 ✅ v0.31.2
    compact (single-line) ❌ https://api.github.com/repos/1jehuang/jcode/releases/342601544 ✅ v0.31.2

    On the compact response the OLD grep '"tag_name"' | cut -d'"' -f4 returns the url field instead of the tag. The proposed grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4 extracts only the tag_name substring and works for both formats — no jq dependency added.

  2. added
    bug
    priority: medium
    triage: reproducible
    autonomous: clear
    on Jun 29, 2026
  3. 1jehuang commented on Jun 29, 2026

    @1jehuang
    Owner

    Triage: reproducible, autonomous: clear. GitHub's /releases/latest now returns compact single-line JSON, so grep '"tag_name"' | cut -d'"' -f4 matches the whole blob and returns a URL. Fixed by isolating the field with grep -o '"tag_name" *: *"[^"]*"' (works for compact and pretty JSON). Fix in #417.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: mediumtriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions