Skip to content

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

Open
keith-mvs wants to merge 3 commits 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 3 commits 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 of Windows-like environments (Git Bash, MSYS2, Cygwin) and ensured executables use the correct .exe extension for discovery, installation, and first-run downloads.
  • Chores

    • Pinned CI runtime image to a verified version to keep end-to-end embedding snapshots deterministic and prevent drift between runs.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 008574d8-4eb0-4b37-a651-576008e5e958

📥 Commits

Reviewing files that changed from the base of the PR and between f972ac9 and a06abaa.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

Normalize Windows-like uname outputs to OS="windows" and set EXT=".exe" in scripts/run so binary discovery and download target use platform-specific filenames; pin the CI Ollama service image to ollama/ollama:0.24.0 for deterministic E2E embeddings.

Changes

Windows Platform and Executable Path Handling

Layer / File(s) Summary
Windows platform detection and binary candidates
scripts/run
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.

CI Runtime Pinning

Layer / File(s) Summary
Pin Ollama service image
.github/workflows/ci.yml
Change E2E job Ollama service image from ollama/ollama:latest to ollama/ollama:0.24.0 with inline notes about embedding snapshot determinism and observed :latest drift.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • ory/lumen#159: Related edits to the cross-OS scripts/run launcher behavior and platform handling.

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 accurately describes the main change: fixing binary resolution for Windows Git Bash/MSYS2/Cygwin environments in the scripts/run launcher.
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

CLAassistant commented Jun 4, 2026

CLA assistant check
All committers have signed the CLA.

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

The E2E job's lang suite (TestLang_*) compares committed embedding snapshots
in testdata/snapshots/. Those rankings are produced by all-minilm via the
Ollama runtime, which the workflow pulled as `ollama/ollama:latest`. Between
the last green main run (2026-05-20) and 2026-06-04 the `:latest` tag advanced
from 0.24.0 to a newer build, changing the embedding vectors and breaking every
snapshot. This is unrelated to the scripts/run change in this PR and would also
fail on main if re-run.

Pin the service image to 0.24.0 (digest
sha256:a6149234667efc71d37766d61c1a16f24c33e4cd7a0bf4125c44a7e47e2419c4) — the
last runtime the snapshots were verified green against — so the suite is
reproducible.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

82-82: ⚡ Quick win

Consider appending the digest to guarantee immutability.

The comment on line 81 documents the specific digest, but the image specification uses only the tag. While Docker tags for official images are generally stable, appending the digest ensures absolute reproducibility even if the tag is republished.

🔒 Proposed enhancement for immutable image reference
-        image: ollama/ollama:0.24.0
+        image: ollama/ollama:0.24.0@sha256:a6149234667efc71d37766d61c1a16f24c33e4cd7a0bf4125c44a7e47e2419c4
🤖 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 @.github/workflows/ci.yml at line 82, Update the GitHub Actions image
reference to an immutable digest by appending the documented sha256 to the
existing image name (replace the current "image: ollama/ollama:0.24.0" value
with the same image reference including the `@sha256`:<digest> suffix), ensuring
the workflow uses the exact digest pinned image; keep the tag if desired but
include the `@sha256` to guarantee reproducibility.
🤖 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.

Inline comments:
In @.github/workflows/ci.yml:
- Line 82: The pinned Ollama image digest is incorrect for the tag used; update
the image reference on the image: ollama/ollama:0.24.0 line to either remove the
digest and rely on the tag or pin to the correct digest for the target
architecture (e.g., use amd64
sha256:7db82c93ff9fae4011a2aa10931b1d2c2a228d508b8736366e3fbaee616b2e8c or arm64
sha256:32f9c3895f3a37cfcf637da5cabfd2d5d600cf3222ab294b366dae316e429589), or pin
the multi-arch manifest digest if you need deterministic images; also add/enable
a vulnerability scan step in the workflow and ensure runtime exposure controls
(do not expose the Ollama API without auth) are enforced rather than relying on
“no known vulnerabilities.”

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Line 82: Update the GitHub Actions image reference to an immutable digest by
appending the documented sha256 to the existing image name (replace the current
"image: ollama/ollama:0.24.0" value with the same image reference including the
`@sha256`:<digest> suffix), ensuring the workflow uses the exact digest pinned
image; keep the tag if desired but include the `@sha256` to guarantee
reproducibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 56d69879-512e-460a-bb2c-686b888fdaf3

📥 Commits

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

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment thread .github/workflows/ci.yml
The annotated digest (sha256:a614...19c4) is the multi-arch manifest-list
(index) digest for the 0.24.0 tag -- the value `docker pull` resolves the tag
to -- not a per-architecture child manifest (amd64 7db82c93..., arm64
32f9c389...). Word the comment so the digest isn't misread as a per-arch image
digest. Comment-only change; the image is still pinned by tag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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