Repository navigation
windows: launch airc cmd shim through bash directly - #542
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR shortens the Windows launch chain for airc by making airc.cmd invoke Git Bash directly (instead of hopping through PowerShell), aligns install.ps1’s generated fallback shim with the same behavior, and adds an integration guard to prevent regressions in the .cmd shim path.
Changes:
- Update
airc.cmdto locate Git Bash and execute the bashaircscript directly. - Update
install.ps1fallback shim generation to match the new direct-bash.cmdlauncher. - Add an integration scenario that asserts
airc.cmdno longer routes through PowerShell and forwards directly to bash.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
airc.cmd |
Replaces PowerShell hop with direct Git Bash invocation and adds probing logic for bash.exe. |
install.ps1 |
Updates generated .cmd fallback shim content to match the new direct-bash launcher. |
test/integration.sh |
Adds a scenario to assert the .cmd shim uses Git Bash directly and doesn’t regress to PowerShell. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if exist "%ProgramFiles%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%ProgramFiles(x86)%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles(x86)%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%LOCALAPPDATA%\Programs\Git\bin\bash.exe" set "BASH_EXE=%LOCALAPPDATA%\Programs\Git\bin\bash.exe" | ||
| if not defined BASH_EXE for %%B in (bash.exe) do if not "%%~$PATH:B"=="" set "BASH_EXE=%%~$PATH:B" |
Comment on lines
+27
to
+28
| if not defined BASH_EXE if exist "%ProgramFiles(x86)%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles(x86)%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%LOCALAPPDATA%\Programs\Git\bin\bash.exe" set "BASH_EXE=%LOCALAPPDATA%\Programs\Git\bin\bash.exe" |
| if exist "%ProgramFiles%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%ProgramFiles(x86)%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles(x86)%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%LOCALAPPDATA%\Programs\Git\bin\bash.exe" set "BASH_EXE=%LOCALAPPDATA%\Programs\Git\bin\bash.exe" | ||
| if not defined BASH_EXE for %%B in (bash.exe) do if not "%%~$PATH:B"=="" set "BASH_EXE=%%~$PATH:B" |
Comment on lines
+284
to
+285
| if not defined BASH_EXE if exist "%ProgramFiles(x86)%\Git\bin\bash.exe" set "BASH_EXE=%ProgramFiles(x86)%\Git\bin\bash.exe" | ||
| if not defined BASH_EXE if exist "%LOCALAPPDATA%\Programs\Git\bin\bash.exe" set "BASH_EXE=%LOCALAPPDATA%\Programs\Git\bin\bash.exe" |
joelteply
added a commit
that referenced
this pull request
May 6, 2026
Pre-fix `install.sh` line 451 used `ln -sf "$CLONE_DIR/airc" "$BIN_DIR/airc"`. On real Linux/macOS this is a real symlink that the kernel resolves to the canonical airc each invocation — `airc update` propagates instantly. On Git Bash for Windows, `ln -sf` is silently a literal COPY (Developer Mode is off by default; Git for Windows can't make NTFS symlinks). That's why a 112KB May-5 copy of the full airc bash script sat at `C:\Users\<user>\.local\bin\airc` for weeks: every `airc update` (run from WSL) refreshed `~/.airc-src/` on the WSL side, but the Windows PATH copy stayed frozen. Claude Code's Monitor on Windows resolves `airc` via Git Bash's `which`, found the stale copy first, and silently ran months-old code while `airc version` (which goes through the .cmd shim) reported the new SHA. Diagnosed today during the post-#543 Monitor-cold-start investigation. Fix per Joel's directive (#543 follow-up): > Any Windows-visible airc on PATH must be a shim, not a copied full > bash script. The shim should route to the canonical WSL install > when WSL ~/.airc-src/airc exists. Native Windows fallback remains > only when no WSL OR AIRC_WINDOWS_NATIVE=1. New file `airc.shim` — polyglot bash routing shim: 1. AIRC_DIR explicit → exec that 2. We're in WSL ourselves → exec $HOME/.airc-src/airc directly (handles "user invokes /mnt/c/.../bin/airc from WSL bash") 3. AIRC_WINDOWS_NATIVE=1 → skip WSL branch 4. wsl.exe present + WSL canonical exists → route via wsl.exe (uses printf %q to forward args correctly — wsl.exe doesn't forward positional args after `-lc`, so they must be inlined into the bash command string. Same root cause as #544.) 5. Native Windows clone at %USERPROFILE%\.airc-src → exec that 6. Loud failure with all attempted paths `install.sh` updated: on MINGW/CYGWIN/MSYS hosts, drop the polyglot shim into BIN_DIR/airc + BIN_DIR/relay instead of `ln -sf`'ing the full bash script. Also clean any pre-existing full-script copy left by prior installs (best-effort `rm -f` is enough). Real Linux/macOS keeps the symlink — that's the right tool there. Verified locally on Windows + WSL2 (canary tip + this branch): - cmd /c airc.cmd version → routes via wsl.exe → canonical - "C:\Program Files\Git\bin\bash.exe" airc version → shim → canonical - wsl bash -lc /mnt/c/.../bin/airc version → shim detects WSL → canonical All three contexts hit the same canonical SHA. No more dual-clone drift. Follow-up — install.ps1 should also drop the polyglot shim at %USERPROFILE%\.local\bin\airc so Git Bash users who installed via the Windows-native path also get a shim instead of nothing on Git Bash's default PATH. Deferred to a separate PR for review-scope hygiene. Related context: #542: airc.cmd direct cmd→bash (drop PowerShell hop) #543: dual-clone single-source — airc.cmd prefers WSL clone #544: airc.cmd args-forwarding (wsl.exe doesn't forward $@) THIS: extend single-source to ALL Windows-visible PATH copies, not just airc.cmd. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 6, 2026
joelteply
added a commit
that referenced
this pull request
May 6, 2026
Pre-fix this function was the last self-killer in the join cold-start
path. Three failure shapes combine — fixing only one was insufficient:
(1) Same-PID self-kill after re-exec. After `_reexec_into host`,
the new airc inherits the SAME pid as the pre-exec instance.
airc.pid (written early per #541) names US. Without filtering
$$/$PPID, the kill loop SIGTERM'd its own shell. Defensive
pattern already exists in _join_scope_transport_pids:211 — was
never propagated to airc.pid contents until now.
(2) OS PID recycling. The other PID sources (airc.pid contents from
a crashed predecessor, bearer_gist.*.pid stragglers) can name
a slot the kernel has since reassigned to an unrelated process
— including, on Windows WSL2, the parent wsl.exe / cmd.exe
shell in our launcher chain. Killing one of those takes Claude
Code's Monitor down with us. Joel hit this exact shape in #97 /
#446 in different code paths; the fix there ("verify cmdline
before treating PID as ours") was never propagated here.
(3) set -e + pipefail kills the whole airc on best-effort PID
assembly. The function uses `proc_airc_pids_matching` (pgrep)
which exits 1 when no matches. Pipefail propagates the 1
through `pgrep | tr`, the simple var assignment then triggers
set -e, and airc dies between debug-instrumented "step1" and
"step2" markers — never reaching the kill loop, never returning
from the function. This was the residual death point that
made my earlier $$ filter alone look ineffective. Joel's
"Codex and Claude usually miss the obvious" call applies.
Fix:
Layer 1 — drop $$ and $PPID from the candidate list.
Layer 2 — verify cmdline matches airc/airc_core before killing,
so an OS-recycled PID owned by an unrelated process is
never targeted.
Layer 3 — wrap each substitution in `|| true` so pipefail can't
propagate pgrep's empty-result-1 into a fatal var
assignment.
Verified end-to-end on Windows + WSL2 (with #544 + #545 also applied
locally). Monitor's `airc join` flow:
shim → wsl.exe → canonical airc → join → discover → take over
→ re-exec to host mode → trust-existing-monitor short-circuit
→ degraded transport detected → _join_restart_scope_processes
→ filters $$ (PID 57724) + dead bearer pids 80413/38943
→ all candidates dropped, kill loop empty, function returns
→ host setup completes through "Hosting #cambriantech (gh-account
substrate)" → "Monitoring for messages..." → broadcast contract
banner → mesh send confirmed bidirectional.
After: Windows Claude Code Monitor `airc join` finally completes
the cold-start path without Joel relay.
Related — Windows Monitor cold-start surface trail:
#533 SIGHUP cascade (transport detach via setsid -f)
#538 monitor 404-gone gist treated as terminal
#541 airc.pid + messages.jsonl created before slow bootstrap
#542 airc.cmd direct cmd→bash (drop PowerShell hop)
#543 dual-clone single-source (airc.cmd prefers WSL)
#544 airc.cmd args-forwarding (wsl.exe doesn't forward $@)
#545 polyglot shim for Windows-visible PATH (single source)
THIS three-layer self-protect on the supervisor restart path.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
May 7, 2026
`wsl.exe sh -lc "<script>" airc %*` does NOT forward the positional
args to the inline script as $0, $1, $@. wsl.exe consumes them itself,
so `$@` inside the script was always empty and `airc.cmd join` ended
up running `exec airc` with no verb. airc fell through to the generic
help banner and exited 0; Claude Code's Monitor on Windows saw airc
print help and silently terminate before any transport spawned.
Symptom from Windows trace just now (`airc.cmd version`): printed
the help banner instead of `airc <sha> on canary`. Same shape was
hiding behind the post-takeover "no existing room — fresh start"
death window: the Monitor's airc.cmd → wsl.exe → sh -lc invocation
was never actually running `airc join`; it was running airc with
no args, which prints help and exits.
Fix:
1. Inline cmd's %* directly into the bash command string, so
positional args are part of the script string before wsl.exe
sees them — bypassing the silent arg-drop.
2. Use `bash -lc` (matches the airc script's #!/bin/bash shebang)
instead of `sh -lc` (dash on Ubuntu). Avoids subtle sh/dash
parser divergence on the same wire shape.
Verified locally:
$ cmd /c airc.cmd version
airc <sha> on canary
Merge pull request #543 ...
install: /home/joel/.airc-src
Pre-fix the same command printed help.
Related context for the Windows Monitor cold-start surface:
#533: SIGHUP cascade (transport detach via setsid -f)
#538: monitor 404-gone gist treated as terminal
#541: airc.pid + messages.jsonl created before slow bootstrap
#542: airc.cmd direct cmd→bash (drop PowerShell hop)
#543: dual-clone single-source — Windows shim prefers WSL clone
THIS: #543 made the WSL-routing path correct in shape but
broke arg-forwarding in implementation.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Windows evidence after #541 showed Claude Code Monitor's 'airc join' hung before the bash airc binary ran at all: no fresh airc.pid, no messages.jsonl, no transport log entries, and no airc process. The remaining failure is upstream of transport attach, in the Windows shim chain.
Tests