PowerShell profile with oh-my-posh fails inside Codex

Open 💬 4 comments Opened Apr 19, 2026 by echocyan
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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:

``powershell
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

<img width="1468" height="850" alt="Image" src="https://github.com/user-attachments/assets/55d6128b-47b5-4702-8443-39d8ec3e59ac" />

<img width="1468" height="850" alt="Image" src="https://github.com/user-attachments/assets/945c423d-4538-4f87-9546-f8d913000a79" />

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_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #17019
  • #17112
  • #17972

Powered by Codex Action

harveylx · 3 months ago

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

tajemniktv · 3 months ago

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

3esmit · 3 months ago

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.