Bash tool drops non-ASCII characters due to LC_CTYPE=C in shell environment
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- bash
- 領域
- cli
調査の方向性
bash tool のサブプロセス起動エントリーポイントから開始し、報告されたロケール、xxd、および非 ASCII パスを使うコマンドで問題を再現します。意図した最小限のシェル起動を維持したまま、シェルが UTF-8 ロケールを受け取ることを確認し、その後、コマンド文字列、ファイルパス、書き込まれた内容でマルチバイト文字が保持されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
The bash tool in Copilot CLI spawns shells with LANG="" and LC_CTYPE="C". This causes all non-ASCII characters (Chinese, Japanese, Korean, accented Latin, emoji, etc.) to be silently stripped from command strings. File paths containing such characters become unresolvable, and file content written via heredoc or echo loses all multibyte characters.
Environment
- Copilot CLI version: 1.0.49
- OS: macOS (Darwin)
- Shell: bash (spawned by Copilot CLI)
Steps to reproduce
- Open Copilot CLI
- Run any bash command involving non-ASCII characters:
echo "ABC你好DEF" | xxd
Expected: 41 42 43 e4bda0 e5a5bd 44 45 46 0a (UTF-8 bytes preserved)
Actual: 41 42 43 44 45 46 0a — the Chinese characters are gone entirely.
- Attempt to write a file to a path containing non-ASCII directory names:
echo "test" > "/path/to/中文目录/file.txt"
Expected: File created successfully.
Actual: Command hangs indefinitely. The shell appears to attempt resolving a corrupted path (with multibyte characters stripped) and never returns.
Root cause
Running locale inside the bash tool confirms:
LANG=""
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
With LC_CTYPE=C, the shell treats all bytes above 0x7F as invalid and discards them during command-line processing. This affects:
- String literals in commands (echo, printf, heredoc content)
- File path arguments containing non-ASCII characters
- Variable assignments with multibyte content
The same operations succeed when run through Python (which manages its own UTF-8 encoding independent of the shell locale), confirming the filesystem and disk are fine.
Suggested fix
Set LANG=C.UTF-8 (or en_US.UTF-8) when spawning bash subprocesses. This preserves the benefits of a minimal locale (deterministic sort order, no locale-dependent formatting surprises) while correctly handling multibyte characters:
env LANG=C.UTF-8 /bin/bash --norc --noprofile -c "..."
Using --norc --noprofile already avoids loading user shell plugins. Adding a UTF-8 locale on top shouldn't introduce any slowness or side effects.
Impact
This bug makes Copilot CLI effectively unusable for any task involving non-English file paths or content — which is common for users working in CJK languages, or anyone whose project happens to have non-ASCII directory names. The failure mode is particularly bad: commands silently produce corrupted output or hang forever, with no error message indicating the cause.
- 主要言語
- Shell
- スター
- 11.2k
- フォーク
- 1.9k
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/copilot-cli のほかの issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
github/copilot-cli#4848 ·
-
area:agents area:mcp
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
github/copilot-cli#4729 ·
-
area:sessions
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
github/copilot-cli#4712 ·
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
github/copilot-cli#4638 ·
-
Expose large_output_file_path on TaskShellProgress so clients can read complete shell-task output オープンarea:tools
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/copilot-cli#4630 · コメント 1 件 ·
github/copilot-cli の issue をすべて見る
似ている issue
-
area: compat bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
intake mcp-intake needs-ac needs-human-review priority:medium type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Ikalus1988/MisakaNet#2019 · コメント 2 件 ·
-
type:content-error
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
stephrobert/blog-roadmap#15 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
hust-open-atom-club/hustmirror-cli#52 · コメント 1 件 ·