Skip to content

Windows: UnicodeEncodeError in Rich output — cp1252 can't encode Unicode chars (em dashes, box-drawing, etc.) #296

@Input-X

Description

@Input-X

Platform

Windows 10 native (Git Bash, Python 3.13.5)

Problem

drone @seedgo --help (and likely any command using Rich formatting with Unicode characters) crashes on Windows with:

UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-41: character maps to <undefined>
  File "rich\_win32_console.py", line 402, in write_text
  File "encodings\cp1252.py", line 19, in encode

Windows terminals default to code page cp1252 (Windows-1252). Rich falls back to its legacy Windows renderer which tries to encode output as cp1252. Characters commonly used in AIPass output — em dashes (), box-drawing chars (┌─┐│└┘), arrows (), etc. — are not in cp1252 and cause a crash.

Reproduction

Fresh Windows 10 clone, after setup:

drone @seedgo --help   # crashes with UnicodeEncodeError
drone systems          # likely affected too
drone @flow list open  # likely affected too

Any drone command that triggers Rich-formatted output will fail on a default Windows terminal.

Fix

Set PYTHONUTF8=1 — forces Python to use UTF-8 for all I/O regardless of locale:

PYTHONUTF8=1 drone @seedgo --help  # works

Where to apply

  1. setup.sh — set PYTHONUTF8=1 before running the verification checks and as a default env var for Windows users
  2. ~/.claude/settings.json env block — so Claude Code sessions inherit it
  3. Windows PATH instructions — tell users to add PYTHONUTF8=1 to their environment permanently (System Properties > Environment Variables)

Suggested setup.sh addition (Windows block):

if [ "$IS_WINDOWS" -eq 1 ]; then
    export PYTHONUTF8=1
    echo "  Set PYTHONUTF8=1 (required for Rich Unicode output on Windows)"
fi

Suggested ~/.claude/settings.json env block addition:

"env": {
  "PYTHONUTF8": "1"
}

Context

Discovered during Windows 10 fresh-clone setup test (issue #294 series).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions