Repository navigation
[Bug] macOS Desktop: missing UTF-8 locale corrupts Chinese Bash input and hangs commands #14337
best-shuke
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
On macOS, the Desktop app's persistent
bashtool can corrupt Chinese command input when its host starts without a UTF-8 locale. Short commands can silently receive different arguments; a longermkdir -pcommand waits for more shell input and eventually reaches the 300-second tool timeout. The original tool-call JSON contains the complete command with balanced quotes.This is a reproducible input problem. The isolated PTY test below changes only the locale and reproduces the failure without any model or network request.
Environment
0.2.2-rc.5/0.2.2-rc.515.6(24G84)arm6444.7.0, Node.js24.21.0bash, backed by the local PTY shell/bin/bash, GNU Bash3.2.57(1)-release--noprofile --norc -iTERM=dumb, 40 rows × 160 columnsstty -echo; set +Hminimal/deepseek-flash, high reasoning effortdanger-full-access, approvalneverLANG,LC_ALL, andLC_CTYPEabsent from the Desktop host's inherited environmentReproduction in Desktop
localethrough the agent'sbashtool. In the affected shell it reports an emptyLANG,LC_CTYPE="C", and an emptyLC_ALL.Expected: the requested directories are created,
OKand the listing are returned, and the tool completes promptly with exit code 0.Actual: the directories are not created and the tool waits. In the recorded session it eventually returned:
The tool's generic message mentions OOM; I have no evidence of an OOM. A controlled PTY reproduction instead shows Bash's secondary prompt,
>, waiting for more input.There is also direct evidence of argument corruption in the affected live shell. This tool call:
returned, in part:
The eight Chinese characters became eight ASCII hyphens, so this is more than a display issue.
Controlled checks
The same command was sent as UTF-8 bytes to a real PTY running
/bin/bash --noprofile --norc -i, afterstty -echo; set +H. The command was wrapped in the persistent tool'sprintf/eval -- $'...'/ status-marker pattern and run in a fresh temporary directory for each case.LANG,LC_ALL,LC_CTYPEabsent>; no directories; no completion markerLC_ALL=C>; no directories; no completion markerLANG=en_US.UTF-8,LC_CTYPE=en_US.UTF-8,LC_ALLabsentOK; completion marker with exit code 0/bin/bash -c,LC_ALL=CStandalone macOS PTY reproducer (Python 3 standard library)
Save this as a UTF-8 Python file and run
python3 reproduce.py. It creates temporary directories and cleans up its own test shells. Expected: the first two cases showb'> 'andcreated: False; the UTF-8 case includes__END__:0andcreated: True.Diagnosis and source pointer
The comparison points to locale-dependent processing of UTF-8 input by interactive Bash/readline. Ordinary noninteractive Bash parses the same command successfully even under the C locale.
In
childEnvironment(), the Bash backend sets terminal and prompt variables but does not supply a UTF-8 character locale. A Desktop host without locale variables therefore starts its shell in the C locale.The runtime reproduction is on
0.2.2-rc.5. I also inspected the abovemasterrevision (4b399c3, after the0.2.3-alpha.2release commit), but have not run the newer Desktop release, so this is not a claim that it has been runtime-tested there.Workaround verified locally
Add the following to the Harness home
.env(~/.dsh/.env), preserving existing entries, and fully quit and reopen Desktop so a fresh host loads it:I verified that a fresh invocation of the bundled
loadLayeredEnv()reads these values and that the isolated PTY command succeeds with them. The original GUI session was not restarted during its active task. This workaround assumes no inheritedLC_ALL=Coverrides the character locale.Suggested upstream handling
Please ensure Bash receives a valid UTF-8 character locale when the Desktop host has no usable one, with platform-appropriate locale availability and precedence handling. A regression test that sends actual UTF-8 Chinese arguments through the persistent PTY path under a missing/C locale would catch both silent argument changes and waiting for additional input.
Related discussion: #7964 concerns Windows prompt escaping and IME input; this report concerns reproducible macOS corruption of agent tool-command input.
中文摘要
macOS 桌面端缺失 UTF-8 locale 时,持久 Bash 工具会破坏输入的中文参数:实际日志中“中文知识竞赛题库”变成八个
-,较长命令则停在>等待补全,最终触发 300 秒超时。缺省/C locale 与 UTF-8 locale 的真实 PTY 对照已复现该差异;非交互式bash -c执行同一命令正常。系统版本、原始命令、日志摘录、独立复现脚本及本地环境变量修复办法均列于上文。All reactions