MoonshotAI / MoonshotAI/kimi-cli
kimi web crashes at startup on Windows when stdout is redirected: UnicodeEncodeError (gbk) in print_banner
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Bug description
kimi web crashes immediately at startup on Chinese-locale Windows when its stdout is redirected (pipe/file) or when it is launched by a parent process that captures stdout. The crash happens while printing the startup banner: the ➜ (U+279C) character cannot be encoded with the locale codec (GBK / cp936), and the unhandled UnicodeEncodeError kills the whole process before the HTTP server binds its port.
As a result, the web server never starts, and a Web UI page already open in the browser shows repeated "实时连接出错 / WebSocket error" toasts because nothing is listening.
Environment
- OS: Windows 11 (10.0.26100), Simplified Chinese locale (ANSI codepage 936 / GBK)
- Kimi Code CLI: v0.28.1, native win32-x64 build (bundled with VS Code extension
moonshot-ai.kimi-code,kimi_cli1.43.0, PyInstaller / Python 3.14)
Steps to reproduce
- On a Chinese-locale Windows machine, redirect stdout, e.g.:
(or launchkimi.exe web --port 58627 --no-open > web.log 2>&1kimi webfrom any parent process that pipes stdout) - The process exits immediately; the port is never bound.
Actual behavior
Traceback (most recent call last):
...
in web:70
in run_web_server:437
in print_banner:118
UnicodeEncodeError: 'gbk' codec can't encode character '➜' in position 4:
illegal multibyte sequence
[PYI-xxxxx:ERROR] Failed to execute script '__main__' due to unhandled exception!
Expected behavior
Banner printing should never crash the server. Please make print_banner encoding-safe (e.g. write with errors="replace", force UTF-8, or drop non-encodable characters) so kimi web starts regardless of stdout encoding / console availability.
What does NOT help
chcp 65001, PYTHONUTF8=1, and PYTHONIOENCODING=utf-8 all fail to prevent the crash when stdout is redirected (verified on v0.28.1).
Workaround
Run kimi web attached to a real console window (cmd / PowerShell / Windows Terminal) and keep that window open — console I/O uses UTF-8 (PEP 528), so the banner prints fine and the server starts normally.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the print_banner entry point mentioned in the traceback and trace how it is called from run_web_server. Reproduce kimi web with stdout redirected under a non-UTF-8 Windows locale, then verify that the banner no longer raises UnicodeEncodeError and the server binds its port.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100