Windows PowerShell 5.1: non-ASCII text piped into a native command arrives as `?`

Abierto Apto para principiantes
#64,139 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@akhil9tiet ya está trabajando en esto.

Desde el 26/11/2026.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
powershell, rust
Área
backend, cli

Línea de trabajo

Empieza leyendo codex-rs/shell-command/src/powershell.rs y la configuración del prefijo en core/src/tools/runtimes/unified_exec.rs, incluido el tratamiento existente para #12496. Reproduce el problema en Windows PowerShell 5.1 con los pasos proporcionados para git commit -F - e inspecciona los bytes del mensaje del commit guardado. Se considera terminado cuando el texto no ASCII enviado por la tubería llega intacto y sin BOM a través de las rutas de prefijo descritas en el issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug CLI tool-calls windows-os
What version of Codex CLI is running?

0.172.0. The code cited below reads the same on today's main.

What subscription do you have?

Free

Which model were you using?

The default model (gpt-6-luna in the 0.156.1 session logs; the problem does not depend on the model)

What platform is your computer?

Windows 11 Home 25H2 (build 26200), Windows PowerShell 5.1.26100, git 2.55.0.windows.3, no PowerShell 7

What terminal emulator and version are you using (if applicable)?

None, codex exec

What issue are you seeing?

When Codex runs a command under Windows PowerShell 5.1, any non-ASCII text that command pipes into a native program reaches the program as ?. The program gets valid ASCII and exits 0, so nothing flags it.

I hit this with agents committing through @'…'@ | git commit -F -. In three runs out of three, a Co-authored-by: Zoé Lefèvre trailer was committed as Zo? Lef?vre, and the agent didn't notice, even the run that read the commit back with git show.

In these sessions Codex ran each command as powershell.exe -Command <command> with nothing before it, so $OutputEncoding, the encoding PowerShell uses for text piped into a native program, kept 5.1's default of ASCII (about_Preference_Variables). The UTF-8 prefix in codex-rs/shell-command/src/powershell.rs:13 doesn't cover this case: it's only added on the unified exec path (core/src/tools/runtimes/unified_exec.rs:549), and it sets [Console]::OutputEncoding, which is about what Codex reads back. PowerShell 7 defaults $OutputEncoding to UTF-8, so this shows up only when Codex falls back to powershell.exe, which is every Windows install without PowerShell 7.

What steps can reproduce the bug?

On Windows without PowerShell 7, ask Codex to run these in an empty folder:

git init -q demo
cd demo
'Zoé Lefèvre' | git -c user.name=x -c [email protected] commit -q --allow-empty -F -
git log -1 --format=%B

It prints Zo? Lef?vre, and the commit holds 0x3F bytes where é and è were. In one run the message also started with a UTF-8 BOM (EF BB BF): when the console's input code page is 65001, 5.1 writes one before anything it pipes to a native program, whatever $OutputEncoding says.

What is the expected behavior?

Zoé Lefèvre, as under PowerShell 7.

Additional information

Setting both encodings before the command fixes both symptoms:

$OutputEncoding = [Console]::InputEncoding = [System.Text.UTF8Encoding]::new()

With that line under Codex on the same machine, piped text arrived byte-exact with no BOM, and setting [Console]::InputEncoding raised no error. Adding it to the prefix, inside its try { } so the constrained language case from #12496 stays quiet, would cover it wherever the prefix runs.

Lenguaje dominante
Rust
Estrellas
136k
Forks
21.6k
Merge medio
1 min
PR fusionados (30 d)
997

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openai/codex

Todos los issues de openai/codex

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.