Skip to content

PowerShell profile with oh-my-posh fails inside Codex #18531

Open

Description

@EchoCyan

What version of Codex CLI is running?

codex-cli 0.121.0 & codex App

What subscription do you have?

Plus

Which model were you using?

gpt-5.4

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

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

Windows Terminal Powershell 7.6.0

What issue are you seeing?

When Codex runs PowerShell commands on Windows, it appears to load my PowerShell profile. My PowerShell profile
contains the following oh-my-posh initialization command:

oh-my-posh init pwsh --config 'catppuccin_mocha' | Invoke-Expression

I have oh-my-posh installed locally. When I open PowerShell myself and run:

notepad $PROFILE

the profile file contains:

oh-my-posh init pwsh --config 'catppuccin_mocha' | Invoke-Expression

This works correctly in my normal local PowerShell session. I can use PowerShell normally, and oh-my-posh loads
without errors.

However, when Codex runs simple PowerShell commands, Codex prints an error from the PowerShell profile:

ResourceUnavailable: C:\Users\Angai\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:1

Line |
   1 | oh-my-posh init pwsh --config 'catppuccin_mocha' | Invoke-Expression
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'oh-my-posh.exe' failed to run: An error occurred trying to start process
     | 'C:\Users\Angai\AppData\Local\Microsoft\WindowsApps\oh-my-posh.exe' with working directory
     | 'C:\code\personal\sky-take-out'. The system cannot access the file.

The actual command that I ask Codex to run still succeeds. For example:

npm -v

prints:

11.12.1

but the PowerShell profile error is also printed in the command output.

This also happens with other simple commands such as:

java -version
mvn -v

The important point is that this error only happens inside Codex. When I run the same commands directly in my own
local PowerShell, there is no error.

So this seems related to the Codex Windows sandbox or the way Codex launches PowerShell processes, rather than a
missing or broken local oh-my-posh installation.

Environment details:

OS: Windows 11
Shell: PowerShell
Workspace: C:\code\personal\sky-take-out
PowerShell profile: C:\Users\Angai\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Profile content:
oh-my-posh init pwsh --config 'catppuccin_mocha' | Invoke-Expression
oh-my-posh path shown in Codex error:
C:\Users\Angai\AppData\Local\Microsoft\WindowsApps\oh-my-posh.exe

Image Image

What steps can reproduce the bug?

  1. Use Codex on Windows with PowerShell as the shell.
  2. Install oh-my-posh locally.
  3. Open a normal local PowerShell session and run:

notepad $PROFILE

  1. Add or confirm that the profile contains this line:

oh-my-posh init pwsh --config 'catppuccin_mocha' | Invoke-Expression

  1. Confirm that this profile works correctly in a normal local PowerShell session.
  2. In Codex, ask it to run a simple PowerShell command, for example:

npm -v

or:

java -version

or:

mvn -v

  1. Observe the command output.

Actual result inside Codex:

The requested command succeeds, but Codex also prints a PowerShell profile error similar to:

Program 'oh-my-posh.exe' failed to run:
'C:\Users\Angai\AppData\Local\Microsoft\WindowsApps\oh-my-posh.exe'
The system cannot access the file.

Comparison outside Codex:

If I open PowerShell directly on the same machine and run the same commands, there is no error. The profile loads
successfully and oh-my-posh works as expected.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    bug
    on Apr 19, 2026
  2. added
    CLI
    windows-os
    sandbox
    on Apr 19, 2026
  3. changed the title [-]PowerShell profile command fails inside Codex CLI and APP[/-] [+]PowerShell profile with oh-my-posh fails inside Codex[/+] on Apr 19, 2026
  4. added
    TUI
    tool-calls
    and removed
    CLI
    sandbox
    TUI
    on Apr 19, 2026
  5. harveylx commented on May 3, 2026

    @harveylx

    Also seeing this, seems like it's resolving the profile directory

  6. tajemniktv commented on May 21, 2026

    @tajemniktv

    yeah, it seems that codex would benefit from having it's own pwsh profile, as if user has any Import-Module or other changes made to the shell, it can be fatal for codex's workflow

  7. 3esmit commented on May 26, 2026

    @3esmit

    Workaround:
    Edit PowerShell_profile.ps1

    In my case (for some reason), this is the place: OneDrive/Documents/PowerShell/Microsoft.PowerShell_profile.ps1

    $isCodexShell = [bool](
        $env:CODEX_THREAD_ID -or
        $env:CODEX_MANAGED_BY_NPM -or
        $env:CODEX_MANAGED_PACKAGE_ROOT
    )
    
    try {
        $isInteractiveShell = -not [Console]::IsInputRedirected -and -not [Console]::IsOutputRedirected
    } catch {
        $isInteractiveShell = $false
    }
    
    if ($isCodexShell) {
        if ($PSStyle) {
            $PSStyle.OutputRendering = 'PlainText'
        }
    
        Remove-Item Env:POSH_* -ErrorAction SilentlyContinue
    } elseif ($isInteractiveShell -and (Get-Command oh-my-posh -ErrorAction SilentlyContinue)) {
        oh-my-posh init pwsh --config "$HOME/.config/omp/powerlevel10k_rainbow.omp.json" | Invoke-Expression
    }
    

    Don't copy and paste this and expect it to run, you need to update oh-my-posh init pwsh --config "$HOME/.config/omp/powerlevel10k_rainbow.omp.json" | Invoke-Expression to your config folder or do something else there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions