Skip to content

fix(run): resolve bundled binary on Windows Git Bash / MSYS2 / Cygwin#174

Open
keith-mvs wants to merge 1 commit into
ory:mainfrom
keith-mvs:fix/windows-git-bash-platform-detection
Open

fix(run): resolve bundled binary on Windows Git Bash / MSYS2 / Cygwin#174
keith-mvs wants to merge 1 commit into
ory:mainfrom
keith-mvs:fix/windows-git-bash-platform-detection

Conversation

@keith-mvs
Copy link
Copy Markdown

@keith-mvs keith-mvs commented Jun 4, 2026

Problem

On Windows under Git Bash (and MSYS2 / Cygwin), scripts/run never finds the
bundled binary and tries to download a non-existent release asset. Because the
launcher is wired as a PreToolUse (Grep|Bash) hook, it exits non-zero on
every tool call, surfacing as a hook error in the agent.

Root cause is platform detection:

OS="$(uname -s | tr '[:upper:]' '[:lower:]')"   # Git Bash -> "mingw64_nt-10.0-26200"

uname -s under Git Bash is MINGW64_NT-<windows-build>, not windows — and
it even embeds the Windows build number (10.0-26200), so it isn't a stable
string. The candidate loop then probes bin/lumen and bin/lumen-${OS}-${ARCH}
with no .exe, never matching the shipped bin/lumen-windows-amd64.exe, and
falls through to:

Downloading lumen v0.0.41 for mingw64_nt-10.0-26200/amd64...

which 404s (lumen-0.0.41-mingw64_nt-10.0-26200-amd64 is not a release asset).

Fix

Normalize mingw*|msys*|cygwin* (and explicit windows*) to windows, and
append .exe to the binary candidates and the download fallback path. The new
case only triggers on those uname strings, so Linux/macOS resolution is
unchanged.

Testing

Git Bash on Windows 11 (uname -s = MINGW64_NT-10.0-26200):

  • scripts/run version -> prints 0.0.41, no "Downloading..." line
  • echo '{}' | scripts/run hook pre-tool-use lumen -> exit 0

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection and handling of Windows-like environments (Git Bash, MSYS2, Cygwin) with enhanced binary discovery and proper executable file extension support during installation.

The launcher derives the platform from `uname -s` lowercased, which under
Git Bash / MSYS2 / Cygwin is `mingw64_nt-<winbuild>` (e.g.
mingw64_nt-10.0-26200), not `windows`. It then probes `bin/lumen` and
`bin/lumen-${OS}-${ARCH}` with no `.exe` suffix, so it never matches the
shipped `bin/lumen-windows-amd64.exe` and falls through to a GitHub download
for a non-existent `lumen-<ver>-mingw64_nt-...-amd64` asset. The download
404s and the PreToolUse (Grep|Bash) hook exits non-zero on every tool call.

Normalize mingw*/msys*/cygwin* to `windows` and append the `.exe` suffix to
the binary candidates (and the download fallback path) so the bundled Windows
binary resolves with no download attempted.

Tested under Git Bash on Windows 11: `scripts/run version` prints the version
with no download, and `hook pre-tool-use` exits 0.

Signed-off-by: Keith Fleming <248089218+keith-mvs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The launcher script (scripts/run) improves Windows environment detection by normalizing uname output patterns (Git Bash, MSYS2, Cygwin) to a standard OS="windows" value and setting .exe file extension. These platform details are then applied to binary candidate lookup and download path resolution.

Changes

Windows Platform and Executable Path Handling

Layer / File(s) Summary
Windows platform detection and binary candidates
scripts/run
Script detects Windows-like uname patterns and normalizes OS to "windows" while setting EXT to ".exe". Binary candidate list is updated to include OS/arch-specific filenames with the computed extension in addition to the generic fallback.
Download target path resolution
scripts/run
When no existing binary is found and download begins, the initial BINARY target path is set to the OS/arch-specific filename including the platform-specific executable extension.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • aeneasr
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing bundled binary resolution on Windows Git Bash/MSYS2/Cygwin platforms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keith-mvs keith-mvs marked this pull request as ready for review June 4, 2026 17:07
Copilot AI review requested due to automatic review settings June 4, 2026 17:07
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

Note

Copilot was unable to run its full agentic suite in this review.

Updates the scripts/run launcher to correctly detect and execute the bundled Windows binary under Git Bash/MSYS2/Cygwin-style environments.

Changes:

  • Normalizes Windows-like uname outputs (mingw/msys/cygwin) to OS=windows.
  • Introduces an executable suffix (.exe) for Windows-family environments so local binary discovery and download targets match packaged artifacts.

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

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/run (1)

55-56: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Windows download URL still omits .exe suffix.

Line 55 and Line 82 build ASSET without ${EXT}, so Windows still requests a non-existent asset name and fails bootstrap download on first run.

🔧 Proposed fix
-  ASSET="lumen-${VERSION#v}-${OS}-${ARCH}"
+  ASSET="lumen-${VERSION#v}-${OS}-${ARCH}${EXT}"
   URL="https://github.com/${REPO}/releases/download/${VERSION}/${ASSET}"
@@
-    ASSET="lumen-${VERSION#v}-${OS}-${ARCH}"
+    ASSET="lumen-${VERSION#v}-${OS}-${ARCH}${EXT}"
     URL="https://github.com/${REPO}/releases/download/${VERSION}/${ASSET}"

Also applies to: 82-83

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/run` around lines 55 - 56, The ASSET variable is built without the
platform-specific extension, so on Windows the download URL (constructed from
ASSET and used in URL) omits the .exe and fails; update the ASSET construction
(and any other places building ASSET, e.g., the second occurrence around where
ASSET is re-set) to append the ${EXT} variable (use
ASSET="lumen-${VERSION#v}-${OS}-${ARCH}${EXT}") and ensure the URL uses that
ASSET so Windows receives the .exe-suffixed artifact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/run`:
- Around line 55-56: The ASSET variable is built without the platform-specific
extension, so on Windows the download URL (constructed from ASSET and used in
URL) omits the .exe and fails; update the ASSET construction (and any other
places building ASSET, e.g., the second occurrence around where ASSET is re-set)
to append the ${EXT} variable (use
ASSET="lumen-${VERSION#v}-${OS}-${ARCH}${EXT}") and ensure the URL uses that
ASSET so Windows receives the .exe-suffixed artifact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 095e5889-8ee5-4a77-8c55-6229020e8eb2

📥 Commits

Reviewing files that changed from the base of the PR and between d0dee0e and 93be76d.

📒 Files selected for processing (1)
  • scripts/run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants