Skip to content

bug: UnicodeDecodeError reading .prompt.md on Windows CP950 — open() missing encoding parameter #604

Closed

Description

@edenfunf

Description

apm run start crashes with a UnicodeDecodeError when the .prompt.md file contains any character outside ASCII on a Windows system with a non-UTF-8 locale encoding (CP950, CP936, CP932).

Steps to Reproduce

  1. Windows machine with a CJK locale (console code page CP950)
  2. apm init my-project && cd my-project
  3. Edit start.prompt.md to include any CJK character (e.g. # 開始)
  4. apm run start

Actual Behaviour

[x] Script execution error: 'cp950' codec can't decode byte 0x8b in position 12: illegal multibyte sequence

Expected Behaviour

The prompt file is read as UTF-8 and the command executes successfully.

Root Cause

Three open() calls in script_runner.py do not pass an explicit encoding parameter:

  • PromptCompiler.compile() — reads the source .prompt.md
  • PromptCompiler.compile() — writes the compiled output file
  • ScriptRunner._execute_script() — reads the compiled file

Without encoding="utf-8", Python uses the platform default (CP950 on affected systems), which cannot decode UTF-8 multi-byte sequences.

Environment

  • OS: Windows 11, console code page CP950
  • apm version: v0.8.11

Activity

  1. added
    bug
    accepted
    on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions