Skip to content

fix(msys): MSYS2_ARG_CONV_EXCL — last layer; cross-machine VERIFIED end-to-end - #177

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-msys-arg-conv-excl
Apr 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-msys-arg-conv-excl

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

continuum-b69f's diagnosis + verify. With this fix Windows airc msg actually lands on Mac host. Verified live: continuum's "WORKING TEST" broadcast IS in my messages.jsonl.

What MSYS does

Even with argparse `--flags`, MSYS Git Bash translates argv VALUES that look like Unix-rooted paths when bash invokes a Windows-native binary. `--host-airc-home /Users/joelteply/.airc` arrived at python.exe as `--host-airc-home C:/Program Files/Git/Users/joelteply/.airc`. Joiner cached the corrupted path. SSH command later failed.

Fix

```bash
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}"
```

Once at airc startup. Targeted prefixes — macOS / Linux / root home dirs excluded from translation; `/tmp/` and `/c/` still translated (needed for local config paths on Windows).

End-to-end verified live

continuum's broadcast `WORKING TEST: Windows-Mac airc msg via continuum-msyspatch` landed in Mac host messages.jsonl. Cross-machine Mac↔Windows airc working end-to-end. First time today.

Mac regression

10 scenarios / 102 assertions green. Env var has no effect on Mac.

Today's chain

27+ PRs from #150 through this. Every layer revealed the next; continuum's traces caught the silent ones. Each fix architecturally correct (no quick fixes per Joel's mandate).

… cross-machine fix (continuum's catch + verify)

continuum-b69f's diagnosis 2026-04-27: even with PR #174 + #176's
argparse `--flags`, MSYS Git Bash on Windows translates argv VALUES
that look like Unix-rooted paths when bash invokes a Windows-native
binary. So `--host-airc-home /Users/joelteply/.airc` arrived at
python.exe as `--host-airc-home C:/Program Files/Git/Users/joelteply/.airc`,
the joiner cached the corrupted path, the SSH command later sent
it to a real Unix host that had no such file. Silent broadcast
failure.

## Fix

```bash
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}"
```

Set once at airc startup, exported, every airc_core invocation
inherits the same translation policy. Targeted prefix list covers
macOS / Linux / root home prefixes without breaking `/tmp/` or `/c/`
paths (which DO need translation for `--config "$CONFIG"` where
$CONFIG is on the local Windows filesystem). Honors a user override
via the `${...:-...}` default-fallback.

## End-to-end verification

continuum-b69f shipped a test broadcast from Windows after their
local patch:

> WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with
> targeted MSYS exclude. should land!

Verified live in MY host's messages.jsonl on Mac:

```
{"from":"continuum-msyspatch","to":"all","ts":"2026-04-27T23:30:13Z",
 "msg":"WORKING TEST: Windows-Mac airc msg via continuum-msyspatch
 with targeted MSYS exclude. should land!","sig":"..."}
```

**Cross-machine Mac↔Windows airc end-to-end working.** This was the
last bug in the chain that started at PR #153 (Microsoft Store
python3 stub).

## Test posture (Mac, where the env var is a no-op)

- tabs 19/19, identity 19/19, whois 5/5, part_persists 8/8,
  list 4/4, general_sidecar_default 12/12, kick 12/12, events 5/5,
  platform_adapters 11/11, whois_cross_scope 6/6

## Today's full chain of cross-machine fixes

#153 → #154 → #155 → #156 → #157 → #158 → #159 → #160 → #162 →
#164 → #165 → #166 → ... → #176 → this. 27+ PRs to ship a working
cross-machine airc on Windows. Every step revealed a new layer.
Copilot AI review requested due to automatic review settings April 27, 2026 23:37
@joelteply
joelteply merged commit 8b55aed into canary Apr 27, 2026
2 checks passed
@joelteply
joelteply deleted the fix/airc-msys-arg-conv-excl branch April 27, 2026 23:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a Windows Git Bash (MSYS) interoperability issue where MSYS rewrites Unix-looking absolute paths in argv values when invoking Windows-native binaries, corrupting host paths exchanged during join/pairing and breaking cross-machine messaging.

Changes:

  • Export MSYS2_ARG_CONV_EXCL at airc startup to exclude common Unix home prefixes from MSYS argv path conversion.
  • Document the motivation and intended scope of the exclusion (avoid breaking /tmp/ and /c/-style local Windows paths).

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

Comment thread airc
Comment on lines +63 to +68
# the targeted exclude covers macOS / Linux / root home prefixes
# without breaking `/tmp/` or `/c/` paths (which DO need translation
# for `--config "$CONFIG"` where $CONFIG is on the local Windows
# filesystem). Set once at airc startup, exported, every airc_core
# invocation inherits the same translation policy.
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}"

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

MSYS2_ARG_CONV_EXCL currently excludes the entire /home/ prefix. In MSYS2 environments, local paths (including $HOME) may also live under /home/<user>/...; excluding /home/ will prevent MSYS from translating those local paths when invoking Windows-native binaries (notably python.exe), which can break PYTHONPATH/lib-dir resolution and other arguments. Consider narrowing the exclusion to just the remote .airc home paths (e.g., patterns that match /home/*/.airc rather than all of /home/), or otherwise avoid excluding local Windows/MSYS home paths.

Suggested change
# the targeted exclude covers macOS / Linux / root home prefixes
# without breaking `/tmp/` or `/c/` paths (which DO need translation
# for `--config "$CONFIG"` where $CONFIG is on the local Windows
# filesystem). Set once at airc startup, exported, every airc_core
# invocation inherits the same translation policy.
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}"
# the exclude must stay narrowly scoped to remote `.airc` home paths
# so local MSYS2 `/home/<user>/...` paths still translate correctly.
# This preserves Unix-style remote homes without breaking `/tmp/`,
# `/c/`, or local `/home/...` paths that DO need translation for
# `--config "$CONFIG"`, PYTHONPATH, and lib-dir arguments on the
# local Windows filesystem. Set once at airc startup, exported,
# every airc_core invocation inherits the same translation policy.
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/*/.airc;/home/*/.airc;/root/.airc;}"

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 27, 2026
…lent-drop catch) (#178)

fix(encoding): export PYTHONIOENCODING=utf-8 at airc startup (continuum's encoding-drop catch)

continuum-b69f traced 2026-04-27: many cross-machine messages were
getting SILENTLY DROPPED on Windows with:

    [airc:formatter] skipped one line: 'charmap' codec can't encode
    character '→' in position 37: character maps to <undefined>

Windows Python defaults to the local code page (cp1252 on US/EU
installs) for stdout. Common Unicode chars — →, em-dash, ✓, etc. —
have no cp1252 codepoint, so `print(...)` raises UnicodeEncodeError.
The formatter's per-line try/except catches it and skips, but from
the user's view the message is just missing from the stream.

## Fix

```bash
export PYTHONIOENCODING="${PYTHONIOENCODING:-utf-8}"
```

Set once at airc startup. Every Python subprocess airc spawns
inherits utf-8 stdio. Honors user override via the default-fallback.
Same shape as MSYS2_ARG_CONV_EXCL (#177) — environment-level fix
that benefits every airc_core invocation without per-callsite changes.

## Why this is the right shape (per Joel's "always the best")

Per-module sys.stdout reconfiguration is also possible, but:
- Requires editing every airc_core module
- Easy to miss a future module
- Doesn't help bash-side code that might also print Unicode

Setting PYTHONIOENCODING once at airc startup is the architectural
answer — Python is told globally to use utf-8 for stdio, and every
subprocess gets the right behavior automatically.

## Test posture

10 scenarios / 102 assertions green on Mac (env var is no-op on Mac
where Python defaults to utf-8 already, but the export is harmless).
Live python3 print of `→ ✓ ⚠ — em-dash` succeeds with the env var set.

## Follow-up

Closes the silent-drop class continuum filed earlier today as #163
(UTF-8 → Latin-1 double-decode). The PYTHONIOENCODING fix is more
general — it covers the OUTPUT side (Windows console encoding) AND
the INPUT side (Python reading stdin will also use utf-8). #163 can
be closed.
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.

2 participants