What happened
Ran the standard one-liner install and it failed silently after detecting the platform. Dug into it and found two separate issues both of which need a fix for the installer to work.
Currently it bails after:
curl -fsSL https://codedb.codegraff.com/install.sh | sh
codedb installer
platform darwin-arm64
Bug 1: Version lookup breaks on a space
The script grabs the latest version from latest.json and parses it with grep:
curl -fsSL "$BASE_URL/latest.json" | grep -o '"version":"[^"]*"' | cut -d'"' -f4
The actual JSON response has a space after the colon:
The grep pattern doesn't account for the space, so matches nothing. The version comes back empty and the script bails out with error: could not fetch latest version.
Fix is to make the regex happy w/ the whitespace:
grep -oE '"version"\s*:\s*"[^"]*"'
I set the version msyelf to work around:
curl -fsSL https://codedb.codegraff.com/install.sh | CODEDB_VERSION=0.2.3 sh
Bug 2: Cloudflare blocks the binary download
Even after getting past the version issue, the actual binary download failed with a 404:
error: download failed
url: https://codedb.codegraff.com/v0.2.3/codedb-darwin-arm64
The file is there, visiting the same URL in a browser downloads it fine. The issue is that Cloudflare is blocking requests with curl's default user-agent. Spoofing a browser user-agent works sometimes but not reliably. Probably some some kind of bot detection or rate limiting on their end.
Fixed it by providing a ~valid user agent.
curl -fsSL -A "Mozilla/5.0" "$url" -o "$tmp"
What happened
Ran the standard one-liner install and it failed silently after detecting the platform. Dug into it and found two separate issues both of which need a fix for the installer to work.
Currently it bails after:
Bug 1: Version lookup breaks on a space
The script grabs the latest version from
latest.jsonand parses it with grep:The actual JSON response has a space after the colon:
{ "version": "0.2.3" }The grep pattern doesn't account for the space, so matches nothing. The version comes back empty and the script bails out with
error: could not fetch latest version.Fix is to make the regex happy w/ the whitespace:
grep -oE '"version"\s*:\s*"[^"]*"'I set the version msyelf to work around:
curl -fsSL https://codedb.codegraff.com/install.sh | CODEDB_VERSION=0.2.3 shBug 2: Cloudflare blocks the binary download
Even after getting past the version issue, the actual binary download failed with a 404:
The file is there, visiting the same URL in a browser downloads it fine. The issue is that Cloudflare is blocking requests with curl's default user-agent. Spoofing a browser user-agent works sometimes but not reliably. Probably some some kind of bot detection or rate limiting on their end.
Fixed it by providing a ~valid user agent.