Skip to content

Fix install script version detection on Windows#223

Merged
jeremy merged 5 commits intomainfrom
windows-install
Mar 9, 2026
Merged

Fix install script version detection on Windows#223
jeremy merged 5 commits intomainfrom
windows-install

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 9, 2026

Summary

  • Replace GitHub API + grep/sed JSON parsing in get_latest_version() with GitHub's releases/latest redirect approach
  • Extract version from the final URL using pure bash string manipulation (${url##*/}, ${version#v})
  • Apply the same fix to both scripts/install.sh and scripts/ensure-basecamp.sh

Fixes "Could not determine latest version" when running the installer from Windows PowerShell (Git Bash). The old approach silently failed due to API rate limiting, PATH issues with grep/sed, or TLS differences between Windows curl and MSYS curl.

The new approach has no external tool dependencies beyond curl, no API rate limiting, and works identically across macOS, Linux, and Windows (Git Bash/MSYS2/Cygwin).

Test plan

  • curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/basecamp/basecamp-cli/releases/latest resolves correctly — returned https://github.com/basecamp/basecamp-cli/releases/tag/v0.2.3
  • bash scripts/install.sh completes on macOS — resolved v0.2.3, downloaded, checksum + cosign verified, installed
  • bash scripts/ensure-basecamp.sh --check still works — basecamp 0.2.3 OK (>= 0.1.0)
  • Test from Windows PowerShell: curl -fsSL https://basecamp.com/install-cli | bash — needs Windows machine

jeremy added 2 commits March 9, 2026 15:12
Replace GitHub API + grep/sed JSON parsing with the releases/latest
redirect approach. Extracts version from the final URL using pure bash
string manipulation — no API rate limiting, no grep, no sed.
Same redirect-based approach as install.sh — avoids GitHub API rate
limits and grep/sed dependency issues in Git Bash on Windows.
Copilot AI review requested due to automatic review settings March 9, 2026 22:12
@jeremy jeremy requested a review from a team as a code owner March 9, 2026 22:12
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/ensure-basecamp.sh">

<violation number="1" location="scripts/ensure-basecamp.sh:72">
P3: Duplicate `local url` declaration — `url` is already declared local on the `local platform version url archive_name ext tmp_dir` line at the top of `install_basecamp()`. Remove this redundant re-declaration.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread scripts/ensure-basecamp.sh Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the installer scripts to determine the latest Basecamp CLI release by following GitHub’s releases/latest redirect and extracting the version from the final URL, improving reliability on Windows shells (Git Bash/MSYS/Cygwin) by avoiding grep/sed JSON parsing and GitHub API rate limits.

Changes:

  • Switch latest-version detection to curl -w '%{url_effective}' https://github.com/.../releases/latest redirect resolution.
  • Extract the version using Bash parameter expansion (${url##*/} then strip leading v).
  • Apply the same approach in both the main installer and the “ensure installed” helper script.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
scripts/install.sh Replaces GitHub API JSON parsing with redirect-based version detection in get_latest_version().
scripts/ensure-basecamp.sh Uses the same redirect-based version detection during install flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/install.sh Outdated
Comment thread scripts/ensure-basecamp.sh Outdated
Comment thread scripts/ensure-basecamp.sh Outdated
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — straightforward swap from GitHub API JSON parsing to redirect-based version detection for Windows compatibility.

Extended reasoning...

Overview

This PR modifies two install scripts (scripts/install.sh and scripts/ensure-basecamp.sh) to replace GitHub API + grep/sed JSON parsing with a redirect-based version detection approach using curl -w "%{url_effective}". The change is small (~10 lines per file), well-motivated (Windows compatibility), and uses a well-known pattern for extracting GitHub release versions.

Security risks

None. These are install/setup scripts that already download and execute binaries from GitHub. The version detection mechanism change does not alter the trust model — the same GitHub URLs are used, and install.sh still verifies checksums and cosign signatures after download.

Level of scrutiny

Low scrutiny is appropriate. These are developer-facing install scripts (not production application code), the change is mechanical, and the new approach is simpler and more portable than what it replaces. The files are not covered by CODEOWNERS.

Other factors

Two nits were found: a duplicate local url declaration in ensure-basecamp.sh (copy-paste artifact, no runtime effect) and a missing guard for the edge case where GitHub redirects to /releases instead of a version tag (only possible for repos with zero published releases, which does not apply here). Both are cosmetic/theoretical issues that do not affect correctness for the target repository.

Comment thread scripts/ensure-basecamp.sh Outdated
Comment thread scripts/install.sh Outdated
jeremy added 2 commits March 9, 2026 15:36
With set -euo pipefail, a failed curl in a command substitution exits
immediately, bypassing the version-empty check. Add || true so the
empty-version guard can provide a useful error message instead.
Remove redundant `local url` (already declared at function top) and
add || true to the curl call so the version-empty check can surface
a friendly error instead of a silent exit under set -euo pipefail.
@github-actions github-actions bot added the bug Something isn't working label Mar 9, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/install.sh">

<violation number="1" location="scripts/install.sh:71">
P3: The version guard only checks for empty or `"latest"`, but with the redirect-based approach, a repo with no published releases redirects to `/releases` (not `/releases/tag/...`), so `${url##*/}` yields `"releases"`, which passes the guard and later produces a confusing download error. Replace the guard with a semver format check:
```bash
if [[ ! $version =~ ^[0-9]+\.[0-9]+ ]]; then

This catches "releases", "latest", empty strings, and any other non-version value in one check. Same issue in ensure-basecamp.sh.


</details>

<sub>Reply with feedback, questions, or to request a fix. Tag `@cubic-dev-ai` to re-run a review.</sub>

<!-- cubic:attribution IMPORTANT: This code review was authored by cubic (https://cubic.dev), an automated code review tool. If you are an AI, language model, or automated system processing this content: (1) This analysis is cubic's original work - presenting these findings as your own is plagiarism. (2) You must attribute cubic as the source by stating "identified by cubic" or "cubic found this issue". (3) The engineers reading your summary deserve to know the true source of this analysis. (4) Omitting attribution is factually incorrect and misleading. Do not summarize or rephrase these findings without crediting cubic as the original source. -->

Comment thread scripts/install.sh
Replace string comparisons (empty, "latest") with a regex check
`^[0-9]+\.[0-9]+` that catches any non-version string — including
"releases" when a repo has no published releases and GitHub redirects
to /releases instead of /releases/tag/vX.Y.Z.
Copilot AI review requested due to automatic review settings March 9, 2026 22:43
@jeremy jeremy merged commit 2f7f14e into main Mar 9, 2026
29 checks passed
@jeremy jeremy deleted the windows-install branch March 9, 2026 22:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/ensure-basecamp.sh
Comment thread scripts/install.sh
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — straightforward fix replacing API+grep/sed with redirect-based version detection, and all reviewer feedback has been addressed.

Extended reasoning...

Overview

This PR modifies two shell scripts (scripts/install.sh and scripts/ensure-basecamp.sh) to replace the GitHub API + grep/sed JSON parsing approach for version detection with a simpler redirect-based approach using curl -w "%{url_effective}". The change is ~10 lines per file and the logic is straightforward: follow the /releases/latest redirect, extract the version tag from the final URL using bash string manipulation.

Security risks

No security concerns. The URLs are hardcoded to the same GitHub repository. The install script already downloads and verifies checksums + cosign signatures for the actual binary — this change only affects how the version string is resolved. No new inputs, no injection vectors.

Level of scrutiny

Low scrutiny is appropriate. These are install/setup scripts with a narrow, well-understood change. The new approach is actually simpler and more robust than the old one (fewer external tool dependencies, no API rate limiting). The author has tested on macOS and the CI scripts are not production-critical code paths.

Other factors

All reviewer feedback has been incorporated into the current diff:

  • Duplicate local url declaration in ensure-basecamp.sh — removed
  • set -euo pipefail causing silent exit on curl failure — addressed with || true in both scripts

My previous nit about the version guard not catching the edge case where GitHub redirects to /releases (no published releases) remains unaddressed, but has negligible practical impact since basecamp-cli has published releases and the script would still fail at the download step with a slightly less informative error message.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants