Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shell): non-ASCII Windows PATH entries survive the PowerShell environment probe #37154

Mergedlowlyleon(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/37154/headmerged by juliusmarminge View on GitHub

Problem

On Windows, T3 Code reads PATH, FNM_DIR and FNM_MULTISHELL_PATH from PowerShell at startup, in the desktop app and in the server. PowerShell writes redirected output in the console code page (850 on a German system, 437 on a US one), and both probes decode it as UTF-8. Every non-ASCII character comes back as U+FFFD:

Value in the environmentWhat the probe returns
C:\Users\Jürgen\GrüßeC:\Users\J�rgen\Gr��e

For a Windows account such as Jürgen, the directories the probe adds to PATH do not exist, and the fnm variables point nowhere. Tools that are reachable only through those entries are reported as not found.

Change

Both probe scripts set [Console]::OutputEncoding to UTF-8 without a BOM before they write. The statement sits in a try/catch, so a host that cannot change its console encoding behaves as it does today.

The change is in two files because the desktop app has its own copy of the probe script (DesktopShellEnvironment.ts) next to the shared one (packages/shared/src/shell.ts).

Scope

Small fix of an obvious bug, so there is no issue. #25801 fixed the same kind of decoding problem for az output.

#35702 edits the same two files for a different problem (carriage returns) and does not touch the encoding.

Verification

Windows 11, German system locale, console code page 850, with C:\Users\Jürgen\Grüße in an environment variable:

ShellWithout the changeWith the change
PowerShell 7 (pwsh.exe)C:\Users\J�rgen\Gr��eC:\Users\Jürgen\Grüße
Windows PowerShell 5.1 (powershell.exe)C:\Users\J�rgen\Gr��eC:\Users\Jürgen\Grüße

Unit tests:

  • packages/shared/src/shell.test.ts, "reads a non-ASCII value from the real shell": runs the real probe on Windows. It fails without the change with C:\Users\J�rgen\Gr��e and passes with it. Skipped on other platforms.
  • packages/shared/src/shell.test.ts, "asks PowerShell for UTF-8 output": runs on every platform and checks the script the probe sends.
  • apps/desktop/src/shell/DesktopShellEnvironment.test.ts, "asks PowerShell for UTF-8 output on Windows": fails without the change and passes with it; the file's 28 tests pass. Run on Linux, because this test file fails on my Windows machine with and without the change (its temp directory resolves to undefined\temp).

Not checked. The packaged desktop app under a Windows account with a non-ASCII name.


Drafted with Claude Fable 5.2 in T3 Code; found by Claude Opus 5.5. The tests and the PowerShell runs are from my own machines.

    1. Pushedbb0b307

    2. Evidence

      Windows Server 2025, Windows PowerShell 5.1, code page 437; real Electron app, fresh isolated state, light theme, identical 1100×780 viewport.

      1. Create C:\Users\Jürgen\Grüße\codex.cmd printing codex-cli 0.130.0, and prepend its directory through the PowerShell profile.
      2. Launch each revision, choose Start without an agent, then open Settings → Providers.
      3. Base reports Codex missing. Head discovers v0.130.0; its Incompatible status is expected for the synthetic stub.
      BeforeAfter
      370b1fde77bb0b307907
      Before: Codex not foundAfter: Codex v0.130.0 found
      Before recordingAfter recording

      Reproduction driver, fixture, launcher, and recording scripts · Fixture encoding transcript

      Not shown:

      • PowerShell 7 and code page 850 were not exercised; this comparison used Windows PowerShell 5.1 and code page 437.
      • Standalone server environment capture outside Electron was not independently exercised; this proof covers desktop startup and provider discovery.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged thisac00327

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.