fix(cli): force UTF-8 stdout/stderr on Windows console (#643 cluster H-1)#728
Merged
fix(cli): force UTF-8 stdout/stderr on Windows console (#643 cluster H-1)#728
Conversation
…H-1)
The Windows console default codepage (cp1252/cp437) cannot encode the
box-drawing and em-dash glyphs the wizard prints. On a fresh Windows
runner ``mm init`` crashes at the very first banner line:
init_cmd.py:2781 click.secho(" ─────────────")
click/utils.py:321 file.write(out)
UnicodeEncodeError: 'charmap' codec can't encode character '─'
This is a real production bug — every Windows user hits it on the first
``mm init`` invocation, not just CI. Spot-fixing line 2781 leaves every
other unicode glyph in the wizard (em-dash, future additions) as a
latent crash, so reconfigure stdout/stderr at the entry point instead.
The reconfigure happens in the click group callback so it runs before
any subcommand emits output, and is gated on ``sys.platform == "win32"``
so POSIX is a no-op. ``errors="replace"`` degrades a missing glyph to
``?`` instead of crashing — strictly better than the current behavior.
Verification:
- ``test (windows-latest)`` will now pass
``test_init_index_search_via_subprocess`` (cluster H-1).
- POSIX unchanged: ``uv run pytest -m "not ollama"
packages/memtomem/tests/test_cli*.py packages/memtomem/tests/test_init_cmd.py``
(362 passed) and ``test_cli_index_noop_e2e.py`` (2 passed).
Co-Authored-By: Claude <[email protected]>
Owner
Author
CI status — Windows fail is carried-over, not from this PR
Net effect of this PR alone: cluster H-1 ( Admin merge (feedback_green_ci_admin_merge.md) is appropriate here — required check is red but the redness is unrelated to this diff. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Cluster H-1 of #643 — Windows console default codepage (cp1252/cp437) cannot encode the box-drawing and em-dash glyphs the wizard prints, so
mm initcrashes at the very first banner line on a fresh Windows runner.This is a production bug, not a test-only artifact: every Windows user hits it on the first
mm initinvocation.Stack from the failing CI run (sha 88c3e81):
Approach
Spot-fixing line 2781 leaves every other unicode glyph (em-dash, future additions) as a latent crash. Reconfigure
sys.stdout/sys.stderrat the CLI entry point (thecli()group callback runs before any subcommand emits output), gated onsys.platform == "win32"so POSIX is a no-op:errors="replace"degrades a missing glyph to?instead of crashing — strictly better than the current behavior.Test plan
uv run pytest -m "not ollama" packages/memtomem/tests/test_cli.py packages/memtomem/tests/test_cli_status.py packages/memtomem/tests/test_init_cmd.py— 355 passed.uv run pytest -m "not ollama" packages/memtomem/tests/test_cli_index_noop_e2e.py— 2 passed.uv run ruff check+uv run ruff format --checkon the touched file.test (windows-latest)will turntest_init_index_search_via_subprocessfrom FAIL → PASS (cluster H-1 of the Windows compat sweep).Cluster H-2 (
test_force_overrides_db_lock) is a separate root cause and ships in a follow-up PR.🤖 Generated with Claude Code