Bash tool drops non-ASCII characters due to LC_CTYPE=C in shell environment
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- Une demi-journée
- Accessibilité débutants
- 72/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Calme
- Stack technique
- bash
- Domaine
- cli
Piste de recherche
Commencez au point d’entrée de bash tool qui lance les sous-processus et reproduisez le problème avec la locale indiquée, xxd et des commandes utilisant des chemins contenant des caractères non ASCII. Vérifiez que le shell reçoit une locale UTF-8 tout en conservant le démarrage minimal prévu du shell, puis confirmez que les chaînes de commande, les chemins de fichiers et le contenu écrit préservent les caractères multioctets.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Shell
- Étoiles
- 11.2k
- Forks
- 1.9k
- Merge moyen
- 14 h 16 min
- PR mergées (30 j)
- 6
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/copilot-cli
-
triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/copilot-cli#4848 ·
-
area:agents area:mcp
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/copilot-cli#4729 ·
-
area:sessions
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/copilot-cli#4712 ·
-
triage
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
github/copilot-cli#4638 ·
-
Expose large_output_file_path on TaskShellProgress so clients can read complete shell-task output Ouvertearea:tools
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
github/copilot-cli#4630 · 1 commentaire ·
Toutes les issues de github/copilot-cli
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
danielmiessler/LifeOS#2218 ·
-
docs(agents): strengthen the no-backslash-escaped-backticks rule with an issue-creation example Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
-
technical-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
ll7/robot_sf_ll7#9560 ·
-
Update ghgrab to 2.1.0 Ouvertepackage-update
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
oSoWoSo/vOid_Community_repOsitory#148 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100