Skip to content

[Windows Desktop] PowerShell 7 cannot be correctly applied, but fixed on PowerShell 5 #23455

@VITRENZA

Description

@VITRENZA

What version of the Codex App are you using (From “About Codex” dialog)?

26.518.11428

What subscription do you have?

Subscription:ChatGPT Plus

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Codex Windows Desktop lets users select “PowerShell” as the integrated terminal shell, but in my environment this launches Windows PowerShell 5.1 (powershell.exe) instead of PowerShell 7 (pwsh.exe), even though PowerShell 7 is installed and callable.

PowerShell 7 is available:

pwsh --version

result:

PowerShell 7.x.x

But the Codex integrated terminal still starts under Windows PowerShell 5.1:

$PSVersionTable.PSVersion
(Get-Process -Id $PID).Path

Observed result before workaround:

Major Minor Build Revision
5     1     ...

I also tested the proposed windows.shell_path config mentioned in #16579:

[windows]
sandbox = "elevated"
shell_path = 'C:\Program Files\PowerShell\7\pwsh.exe'

After restarting Codex Windows Desktop, this did not change the behavior in my build. The integrated terminal still launched powershell.exe 5.1.

I created a workaround using the Windows PowerShell 5.1 profile as an early trampoline into PowerShell 7:

# Auto-enter PowerShell 7 from Windows PowerShell 5.1
if (
    $PSVersionTable.PSVersion.Major -eq 5 -and
    $Host.Name -eq 'ConsoleHost' -and
    -not $env:__ENTERED_PWSH7
) {
    $env:__ENTERED_PWSH7 = '1'
    & 'C:\Program Files\PowerShell\7\pwsh.exe' -NoLogo
    exit $LASTEXITCODE
}

After placing this at the top of the Windows PowerShell 5.1 current-user all-hosts profile and restarting Codex, the terminal still briefly prints the Windows PowerShell banner, but the actual running process becomes PowerShell 7:

$PSVersionTable.PSVersion
(Get-Process -Id $PID).Path

Observed result after workaround:

Major Minor Patch
7     5     6

C:\Program Files\PowerShell\7\pwsh.exe

This suggests that Codex still starts from Windows PowerShell 5.1 first, and the profile workaround redirects the interactive terminal into PowerShell 7.

What steps can reproduce the bug?

  1. Install PowerShell 7 on Windows.
  2. Confirm that pwsh is available:
pwsh --version
  1. Open Codex Windows Desktop.
  2. Set:
    • Agent environment: Windows native
    • Integrated terminal shell: PowerShell
  3. Open a project in Codex.
  4. Open the integrated terminal.
  5. Run:
$PSVersionTable.PSVersion
(Get-Process -Id $PID).Path

Expected if PowerShell 7 is used:

Major Minor Patch
7     ...

C:\Program Files\PowerShell\7\pwsh.exe

Actual behavior in my environment:

Major Minor Build Revision
5     1     ...

C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
  1. Optional: add the following config to config.toml:
[windows]
sandbox = "elevated"
shell_path = 'C:\Program Files\PowerShell\7\pwsh.exe'
  1. Restart Codex Windows Desktop.
  2. Re-run the same verification commands.

In my build, the shell_path setting did not change the integrated terminal behavior.

What is the expected behavior?

If PowerShell 7 is installed, Codex Windows Desktop should provide a documented and supported way to select pwsh.exe directly.

Possible options:

  • expose “PowerShell 7” / pwsh.exe as a separate integrated terminal option
  • document and support [windows].shell_path
  • allow users to configure the executable behind the generic “PowerShell” label
  • clearly document whether “PowerShell” means Windows PowerShell 5.1, PowerShell 7, or the first detected supported PowerShell executable

The current generic “PowerShell” option is ambiguous because users may assume it uses PowerShell 7 once pwsh is installed, while Codex may still launch Windows PowerShell 5.1.

Additional information

Related issue: #16579

This issue is not intended to duplicate #16579. It adds user-side reproduction details, confirms that windows.shell_path did not work in my current Codex Windows Desktop build, and documents a tested workaround.

The workaround is useful, but it is not a clean replacement for a supported Codex setting. It depends on user-specific Windows PowerShell profile behavior.

Caveat: this workaround is verified for the integrated terminal path. It may not cover every internal Codex tool-execution path if some runner explicitly invokes powershell.exe -NoProfile, bypasses user profiles, or uses a separate execution path.

Additional observation: this workaround also helps when Windows PowerShell 5.1 startup is slowed down by profile hooks such as Conda initialization. Placing the trampoline before slower profile hooks allows the interactive terminal to enter PowerShell 7 before those hooks are executed.

Codex Windows 桌面端目前允许用户选择 “PowerShell” 作为集成终端 shell,但在我的环境里,即使已经安装并可以调用 PowerShell 7,它实际启动的仍然是 Windows PowerShell 5.1,也就是 powershell.exe,而不是 PowerShell 7 的 pwsh.exe

我通过 $PSVersionTable.PSVersion(Get-Process -Id $PID).Path 验证,Codex 集成终端在 workaround 之前实际运行的是 Windows PowerShell 5.1

我也测试了 #16579 中提到的 windows.shell_path 配置,但在我当前的 Codex Windows Desktop build 中没有生效

临时 workaround 是在 Windows PowerShell 5.1 的 current-user all-hosts profile 最顶部加入一段 trampoline 代码,让 Windows PowerShell 5.1 启动后立即进入 PowerShell 7,并退出 5.1

这个 workaround 生效后,Codex 集成终端仍然会短暂显示 Windows PowerShell 的启动横幅,但实际运行进程已经变成 PowerShell 7 的 pwsh.exe

这个 workaround 有用,但它不是官方的一等配置。更理想的方案是 Codex Windows Desktop 提供文档化、受支持的方式,让用户可以直接选择 PowerShell 7 / pwsh.exe

这个问题和 #16579 有关,但不是简单重复。这个 issue 补充了用户侧复现信息、windows.shell_path 在当前 build 中未生效的测试结果,以及一个已验证的临时 workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingconfigIssues involving config.toml, config keys, config merging, or config updateswindows-osIssues related to Codex on Windows systems

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions