Skip to content

fix(cli): force UTF-8 CLI output so status glyphs do not crash on Windows (#396)#397

Merged
imran-siddique merged 3 commits into
mainfrom
fix/cli-utf8-output
Jul 7, 2026
Merged

fix(cli): force UTF-8 CLI output so status glyphs do not crash on Windows (#396)#397
imran-siddique merged 3 commits into
mainfrom
fix/cli-utf8-output

Conversation

@imran-siddique

Copy link
Copy Markdown
Contributor

What

Reconfigures the CLI's stdout/stderr to UTF-8 at the main group entry point.

Why

The CLI prints check/cross status glyphs. Under a non-UTF-8 console (Windows cp1252) writing them raises UnicodeEncodeError, so cmcp validate-config / start crash before doing anything (only PYTHONUTF8=1 works around it today). Surfaced while verifying the agentrust-io/examples quickstarts on Windows.

The fix is guarded (AttributeError/ValueError) for streams that cannot be reconfigured, and keeps the nicer glyphs where the terminal supports them.

Fixes #396.

🤖 Generated with Claude Code

imran-siddique and others added 3 commits July 7, 2026 16:09
…ash on Windows

The cmcp CLI prints check/cross status glyphs. Under a non-UTF-8 console
(Windows cp1252) writing them raises UnicodeEncodeError, so validate-config,
start, etc. exit non-zero before doing anything. Reconfigure stdout/stderr to
UTF-8 at the group entry point (guarded for non-reconfigurable streams).

Fixes #396.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
isinstance(io.TextIOWrapper) narrows the TextIO union so mypy accepts
.reconfigure; contextlib.suppress(ValueError) keeps ruff SIM105 happy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@imran-siddique imran-siddique merged commit 94e24c2 into main Jul 7, 2026
11 checks passed
@imran-siddique imran-siddique deleted the fix/cli-utf8-output branch July 7, 2026 23:19
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.

CLI crashes on Windows (cp1252): UnicodeEncodeError on the ✓/✗ status glyphs

1 participant