Skip to content

Fix Windows compatibility: UTF-8 stdout, pip self-upgrade, complete UA#36

Open
chewinggum604-art wants to merge 1 commit into
PleasePrompto:masterfrom
chewinggum604-art:fix/windows-compatibility
Open

Fix Windows compatibility: UTF-8 stdout, pip self-upgrade, complete UA#36
chewinggum604-art wants to merge 1 commit into
PleasePrompto:masterfrom
chewinggum604-art:fix/windows-compatibility

Conversation

@chewinggum604-art
Copy link
Copy Markdown

Summary

This PR fixes three Windows-specific issues that block first-run setup of the
skill on a fresh install. Tested on Windows 11 with Python 3.12.10 (winget,
user scope) and Chrome 131. No behavior change on macOS/Linux.

What's broken on Windows today

  1. scripts/run.py crashes immediately on first run.
    The runner prints a 🔧 emoji during venv bootstrap. On Windows the default
    console encoding is cp1252, which can't encode \U0001f527. Result:
    UnicodeEncodeError before any work happens.

  2. scripts/setup_environment.py fails the dependency install.
    It upgrades pip via pip.exe install --upgrade pip. Windows can't replace
    pip.exe while it's running (FileLock), so the call returns non-zero,
    check=True raises, and ensure_venv() returns False. Setup aborts.

  3. scripts/config.py ships a truncated USER_AGENT missing the
    (KHTML, like Gecko) Chrome/<ver> Safari/537.36 tail. Truncated UAs are a
    bot-detection signal — minor, but cheap to fix.

Changes

  • scripts/run.py

    • Reconfigure sys.stdout / sys.stderr to UTF-8 with errors='replace'
      at the top of the file (Python 3.7+).
    • Set PYTHONIOENCODING=utf-8 in the env passed to subprocess calls so the
      fix propagates to setup_environment.py, auth_manager.py,
      notebook_manager.py, and ask_question.py when launched via the runner.
  • scripts/setup_environment.py

    • Switch the pip self-upgrade from [venv_pip, "install", ...] to
      [venv_python, "-m", "pip", "install", ...]. This is the standard
      Windows-safe pattern and a no-op cost on POSIX.
  • scripts/config.py

    • Complete USER_AGENT with the full Chrome 131 string.

How to verify

# Fresh clone, no Windows-specific env setup
cd /path/to/clone
python scripts/run.py auth_manager.py status
# Before this PR: UnicodeEncodeError on Windows
# After this PR: prints "🔐 Authentication Status: ..." correctly

# venv bootstrap from scratch (delete .venv and rerun)
rm -rf .venv
python scripts/run.py auth_manager.py status
# Before: "Failed to install dependencies" on Windows
# After: clean bootstrap, status prints

Out of scope (separate PRs if welcome)

A few smaller things I noticed while debugging but kept out of this PR to keep
review focused. Happy to file separately if any are interesting:

  • auth_manager.is_authenticated() only soft-warns when state is older than
    7 days — would benefit from a hard cutoff (e.g., 14 days) so callers don't
    blunder into expired-cookie territory without a clear error.
  • notebook_manager.update_notebook() exists on the class but isn't exposed
    on the CLI; would be nice to have an update subcommand.
  • references/troubleshooting.md consistently says chromium but the skill
    installs Chrome (per setup_environment.py line ~76); also the Linux-only
    pkill -f chromium doesn't help Windows users.

Notes

  • All three changes are minimal, self-contained, and behavior-preserving on
    non-Windows platforms (sys.stdout.reconfigure is a no-op when stdout is
    already UTF-8; python -m pip works the same as pip on POSIX; the longer
    USER_AGENT is just more accurate).
  • Comments at each change site explain the why (Windows constraint), not
    the what, so future readers don't have to re-derive the FileLock or
    cp1252 reasoning.

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.

1 participant