Skip to content

Windows standalone update from pwsh inherits PSModulePath into powershell.exe, causing Get-FileHash to fail #27117

Open

Description

@BlueOcean223

What happened?

While investigating a Windows standalone update failure, I found that the update action launches Windows PowerShell (powershell.exe) even when Codex itself is started from PowerShell 7 (pwsh). The child powershell.exe process can inherit PowerShell 7 entries in PSModulePath, which breaks module discovery in Windows PowerShell 5.1 and makes Get-FileHash unavailable.

The resulting installer failure looks like this:

Get-FileHash : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.

This does not appear to be caused by irm ... | iex corrupting the installer script text. I verified that the downloaded script text and piped script text are identical and parse successfully.

Environment

OS: Windows 10 22H2, 10.0.19045
Codex: codex-cli 0.138.0
Parent shell: pwsh 7.6.2
Child shell used by standalone update: powershell.exe 5.1.19041.6456
Codex executable: C:\Users\Administrator\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe

Current main still has the Windows standalone update action hard-coded as:

UpdateAction::StandaloneWindows => (
    "powershell",
    &[
        "-ExecutionPolicy",
        "Bypass",
        "-c",
        "$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex",
    ],
),

Observed on main commit:

08cb633c06a27d25872d0132fbd9c749556d7653

Minimal reproduction

This does not execute the Codex installer. It only simulates the relevant process-launch shape and checks whether Windows PowerShell can resolve and run Get-FileHash.

Run this from pwsh:

node - <<'NODE'
const { spawnSync } = require('child_process');

const psProbe = String.raw`
$ErrorActionPreference = 'Continue'
"PSVersion=$($PSVersionTable.PSVersion) Edition=$($PSVersionTable.PSEdition)"
"PSModulePath=$env:PSModulePath"
$cmd = Get-Command Get-FileHash -ErrorAction SilentlyContinue
"Get-FileHash found=$([bool]$cmd) type=$($cmd.CommandType) source=$($cmd.Source)"
try {
  'Get-FileHash -LiteralPath $PSHOME\\powershell.exe -Algorithm SHA256 | Select-Object -First 1 Algorithm,Hash' | Invoke-Expression | Format-List
  "InvokeExpressionResult=OK"
} catch {
  "InvokeExpressionResult=FAIL"
  "Error=$($_.Exception.Message)"
}
`;

const enc = Buffer.from(psProbe, 'utf16le').toString('base64');
const cleanWindowsPSModulePath = [
  'C:\\Users\\Administrator\\Documents\\WindowsPowerShell\\Modules',
  'C:\\Program Files\\WindowsPowerShell\\Modules',
  'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules',
].join(';');

const cases = [
  ['A. inherited env, like native child process', { ...process.env }],
  ['B. PSModulePath removed, let Windows PowerShell rebuild', (() => { const e = { ...process.env }; delete e.PSModulePath; delete e.PSMODULEPATH; return e; })()],
  ['C. clean WindowsPowerShell-only PSModulePath', { ...process.env, PSModulePath: cleanWindowsPSModulePath }],
];

for (const [name, env] of cases) {
  const r = spawnSync('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', enc], {
    encoding: 'utf8', timeout: 30000, env
  });
  console.log('\n==== ' + name + ' ====');
  console.log('exit=' + r.status);
  console.log(r.stdout.trim());
  const stderr = r.stderr.replace(/#< CLIXML[\s\S]*/,'<CLIXML progress omitted>').trim();
  if (stderr) console.log('stderr=' + stderr);
}
NODE

Actual output

With the inherited environment, Windows PowerShell 5.1 sees PowerShell 7 module paths first and cannot resolve Get-FileHash:

==== A. inherited env, like native child process ====
exit=0
PSVersion=5.1.19041.6456 Edition=Desktop
PSModulePath=C:\Users\Administrator\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
Get-FileHash found=False type= source=
InvokeExpressionResult=FAIL
Error=The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

If PSModulePath is removed before spawning powershell.exe, Windows PowerShell rebuilds a WindowsPowerShell-only module path and Get-FileHash works:

==== B. PSModulePath removed, let Windows PowerShell rebuild ====
exit=0
PSVersion=5.1.19041.6456 Edition=Desktop
PSModulePath=C:\Users\Administrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
Get-FileHash found=True type=Function source=Microsoft.PowerShell.Utility

Algorithm : SHA256
Hash      : 9785001B0DCF755EDDB8AF294A373C0B87B2498660F724E76C4D53F9C217C7A3

InvokeExpressionResult=OK

Codex-shaped safe reproduction

This mirrors the update action shape (powershell -ExecutionPolicy Bypass -c "... | iex") without running the installer:

==== codex-shaped command, inherited env ====
Get-FileHash : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.

==== codex-shaped command, PSModulePath removed ====
SHA256    9785001B0DCF755EDDB8AF294A373C0B87B2498660F724E76C4D53F9C217C7A3

Why this does not look like an irm | iex encoding problem

I also checked the real installer script without executing it. The direct Invoke-RestMethod result and the piped text had the same length, same SHA-256 over the text, same Get-FileHash index, and both parsed with zero PowerShell parser errors:

directLength=29883
pipeLength=29883
directSha256=ab7d7864801e62f92aa3abf878e3b0aaa8b9f7de03120bc81b029f67281c1842
pipeSha256=ab7d7864801e62f92aa3abf878e3b0aaa8b9f7de03120bc81b029f67281c1842
directParserErrors=0
pipeParserErrors=0
directGetFileHashIndex=2768
pipeGetFileHashIndex=2768

Expected behavior

The standalone Windows update should run reliably when Codex is started from pwsh, without making Windows PowerShell 5.1 inherit a PowerShell 7 module path that breaks module discovery.

Possible fixes

A few possible directions:

  1. Add -NoProfile to the Windows standalone update invocation.
  2. Remove or normalize PSModulePath before spawning powershell.exe for StandaloneWindows, so Windows PowerShell can rebuild its default WindowsPowerShell module path.
  3. Prefer pwsh when Codex itself is running from pwsh and pwsh is available.
  4. Add a fallback in install.ps1 that computes SHA-256 using .NET APIs if Get-FileHash is unavailable.

The most targeted fix seems to be normalizing/removing PSModulePath for the powershell.exe child process used by the Windows standalone update action.

I am happy to help with a PR if maintainers agree with the preferred fix direction.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    on Jun 9, 2026
  2. thomak-dev commented on Jun 18, 2026

    @thomak-dev

    I am having this problem when trying to update codex from PowerShell 7, which is my main shell. The expectation is that codex update works from any shell

  3. rteoo commented on Jul 2, 2026

    @rteoo

    I can confirm this is still reproducible with a newer Codex release and the latest PowerShell 7 available in my environment.

    Environment

    • Windows: 10.0.26200.8655
    • Parent shell: PowerShell 7.6.3
    • Codex CLI: 0.141.0
    • Target update: 0.142.5

    Reproduction

    From PowerShell 7.6.3:

    codex update

    The updater launches Windows PowerShell rather than the current pwsh process:

    Updating Codex via `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'`...
    ==> Updating Codex CLI from 0.141.0 to 0.142.5
    ==> Detected platform: Windows (x64)
    ==> Resolved version: 0.142.5
    ==> Downloading Codex CLI
    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.
    

    Running Windows PowerShell 5.1 independently with a clean environment resolves Get-FileHash from Microsoft.PowerShell.Utility, which is consistent with the root-cause analysis in this issue: the failure is caused by the PowerShell 7 PSModulePath inherited by the powershell.exe child process, not by Get-FileHash being unavailable on the machine.

    Proposed fix

    For the StandaloneWindows update action:

    1. Keep powershell.exe as the compatibility baseline because pwsh is not guaranteed to be installed.
    2. Add -NoProfile.
    3. Remove PSModulePath from the child process environment before spawning powershell.exe, allowing Windows PowerShell to reconstruct its native module search path.
    4. Add a Windows regression test that starts the update command with a PowerShell 7-style PSModulePath and verifies that the child can resolve and execute Get-FileHash.

    A defensive .NET SHA-256 fallback in install.ps1 could provide an additional safety net, but normalizing the child environment appears to be the smallest fix at the source.

    This also appears to be the same failure reported in #30015. I would be happy to prepare the focused change and regression test if a maintainer would like to invite a PR under the repository's contribution policy.

  4. duckyb commented on Jul 6, 2026

    @duckyb

    I tested this solution (proposed by OP) and it worked great for me. If you're having issues updating codex cli I recommend trying it. 👍🏻

    powershell -NoProfile -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'

  5. balloon72 commented on Jul 11, 2026

    @balloon72

    I reproduced this on current main (5c19155cbd93) on Windows, with PowerShell 7.6.3 spawning Windows PowerShell 5.1.26100.8457.

    With the inherited PSModulePath, Get-Command Get-FileHash returned no command. Removing PSModulePath before spawning the same child restored Microsoft.PowerShell.Utility. Both probes used -NoProfile, so adding that flag alone is not sufficient.

    The current standalone Windows path in codex-rs/cli/src/main.rs directly spawns the updater command without adjusting its environment. The smallest fix looks like adding .env_remove("PSModulePath") only for UpdateAction::StandaloneWindows, while keeping powershell.exe and every other update path unchanged.

    I can keep the patch to that focused change and validate it with the PowerShell probe, just test -p codex-cli, just fix -p codex-cli, and just fmt.

    If this matches the intended direction, would a maintainer like me to open an invited PR for this issue?

  6. dzshzx commented on Jul 11, 2026

    @dzshzx

    Confirmed with a full isolated standalone update, not just a command-resolution probe.

    Environment

    • Windows 11 x64: 10.0.26100.8655
    • Parent shell: PowerShell 7.6.3
    • Source Codex: 0.142.5
    • Target Codex: 0.144.1
    • Child updater shell: Windows PowerShell 5.1.26100.8655

    I copied the retained 0.142.5 standalone package into a temporary standalone layout, pointed CODEX_HOME and CODEX_INSTALL_DIR at isolated directories, and ran that binary's real codex update path. The production installation was not used by the update.

    With the inherited environment, instrumentation in the child showed:

    DIAG_PARENT=codex.exe
    DIAG_PSHOME=C:\Windows\System32\WindowsPowerShell\v1.0
    DIAG_PSMODULEPATH=...;C:\Program Files\PowerShell\7\Modules;...;C:\Windows\System32\WindowsPowerShell\v1.0\Modules
    
    Name    : Microsoft.PowerShell.Utility
    Version : 7.0.0.0
    Path    : C:\Program Files\PowerShell\7\Modules\Microsoft.PowerShell.Utility\...
    

    The real installer then failed at the archive verification step with:

    Get-FileHash : The term 'Get-FileHash' is not recognized
    

    I repeated the same isolated update after removing only PSModulePath from the environment inherited by codex.exe. The Windows PowerShell child reconstructed its native module path:

    DIAG_PSMODULEPATH=...\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\System32\WindowsPowerShell\v1.0\Modules
    
    Name    : Microsoft.PowerShell.Utility
    Version : 3.1.0.0
    Path    : C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\...
    

    The Get-FileHash step passed and Codex 0.144.1 was installed into the isolated target. This confirms that the narrow source fix is to remove PSModulePath only on the StandaloneWindows updater child process before spawning powershell.exe.

    PowerShell's documented pwsh -> powershell.exe module-path translation does not apply here because native codex.exe sits between the two shells:

    pwsh.exe -> codex.exe -> powershell.exe
    

    Adding -NoProfile alone does not address the inherited process environment. I am preparing the focused .env_remove("PSModulePath") change and a unit-level command construction test. This is also the same user-visible failure reported in #30015.

  7. dzshzx commented on Jul 11, 2026

    @dzshzx

    The focused implementation is ready for maintainer review:

    Scope:

    • move the existing update-process runner out of the 4,000-line cli/src/main.rs into a focused module;
    • remove PSModulePath only from the StandaloneWindows PowerShell child;
    • keep all other update paths unchanged;
    • add a command-construction regression test that asserts the child environment removal.

    Validation:

    just test -p codex-cli
    295 tests run: 295 passed, 0 skipped
    
    just fix -p codex-cli
    passed
    
    just fmt
    passed
    
    git diff --check
    passed
    

    I have not opened a pull request because docs/contributing.md says external PRs require an explicit maintainer invitation and uninvited PRs are closed without review. If a maintainer confirms this direction and invites the PR, the branch is ready to open immediately.

  8. galar71 commented on Jul 16, 2026

    @galar71

    Confirmed independently on the current standalone release; this is still reproducible in Codex CLI 0.144.5.

    Environment

    • Windows 11 x64
    • Parent shell: PowerShell 7.6.3
    • Windows PowerShell child: 5.1.26100.8875
    • Standalone Codex update: 0.144.4 -> 0.144.5
    • Authentication: ChatGPT account (no API-key installation path involved)

    User-visible reproduction

    Running the ordinary command from PowerShell 7:

    codex update

    downloads the update, then fails during archive verification:

    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet,
    function, script file, or operable program.
    ...
    Error: `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'` failed with status exit code: 1
    

    Opening Windows PowerShell 5.1 and running the same ordinary codex update completed successfully.

    Additional isolation

    Both installed shells have a valid Get-FileHash:

    • PowerShell 7 resolves it from Microsoft.PowerShell.Utility 7.0.
    • Windows PowerShell 5.1 resolves it from Microsoft.PowerShell.Utility 3.1.

    Profiles and user/machine PSModulePath configuration were checked; there are no custom module-path or autoload changes causing this.

    A read-only process-chain probe reproduced the boundary precisely:

    pwsh.exe -> powershell.exe
    Get-FileHash: Microsoft.PowerShell.Utility
    
    pwsh.exe -> native intermediary -> powershell.exe
    Get-FileHash: not found
    

    That matches the production chain:

    pwsh.exe -> codex.exe -> powershell.exe
    

    The direct PowerShell 7-to-Windows PowerShell launch performs PowerShell's documented PSModulePath compatibility translation. Inserting a native process preserves the PowerShell 7 process environment and bypasses that handoff.

    This confirms the report and the focused fix already prepared in this thread: remove PSModulePath from the StandaloneWindows updater child before spawning powershell.exe. The expected behavior is that the literal codex update command works from PowerShell 7 without profiles, wrappers, alternate commands, or switching shells.

  9. Swatto86 commented on Jul 22, 2026

    @Swatto86

    Still reproduces on the latest release. codex update from pwsh 7.6.3 failed updating 0.144.3 → 0.145.0 with the same Get-FileHash error.

    OS: Windows 11 Pro 26200
    Parent shell: pwsh 7.6.3
    Child shell (standalone update): powershell.exe 5.1.26100.8894
    

    Confirmed the exact mechanism described here: the inherited PSModulePath puts PowerShell 7 module dirs ahead of the Windows PowerShell ones, so WinPS 5.1 autoloads the PS7 copy of Microsoft.PowerShell.Utility (from ...\powershell\7\Modules\...), which does not surface Get-FileHash under 5.1. Forcing a clean WinPS-only PSModulePath on the child fixes it:

    $env:PSModulePath = "C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules"
    powershell -ExecutionPolicy Bypass -NoProfile -c "$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex"

    Note -NoProfile alone (fix #1) is not sufficient — the shadowing comes from the inherited PSModulePath, not the profile. Option #2 (normalize/remove PSModulePath before spawning powershell.exe) or #4 (.NET SHA-256 fallback in install.ps1) are the robust fixes.

  10. Rezetyan commented on Jul 27, 2026

    @Rezetyan

    Confirmed on the latest release: 0.144.6 → 0.145.0, with a parent shell combination not yet reported here — pwsh 7.6.4 MSIX (Microsoft Store install) — child powershell.exe 5.1.26100.8894, Windows 11 Pro 26200. Same Get-FileHash CommandNotFound at the checksum step.

    Two findings I haven't seen in this thread yet, plus an explanation of why manually re-running the install command appears to work:

    1. The shadowing module is Microsoft.PowerShell.Utility, and its pwsh build declares CompatiblePSEditions = @("Core")

    With the inherited PSModulePath, Get-Module Microsoft.PowerShell.Utility -ListAvailable in the child 5.1 resolves to the pwsh copy (path order wins over C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules). Its manifest:

    ModuleVersion = "7.0.0.0"
    CompatiblePSEditions = @("Core")
    

    Windows PowerShell 5.1 cannot load this Core-only build and — critically — does not fall back to the compatible copy later in PSModulePath, so Get-Command Get-FileHash returns nothing and install.ps1 dies.

    Shadowing by this single module is sufficient: staging a directory containing only pwsh's Microsoft.PowerShell.Utility, then launching powershell.exe with PSModulePath = <staged dir>;<system32 WinPS modules>, already reproduces Get-FileHash: not recognized. Both pwsh install flavors ship the shadowing content: MSI (C:\Program Files\PowerShell\7\Modules) and MSIX/Store (C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.4.0_x64__8wekyb3d8bbwe\Modules).

    2. Why re-running the command manually from pwsh "works": pwsh hands direct powershell.exe children a clean PSModulePath — a native middle process defeats that

    • pwsh 7.6.4 → powershell.exe (direct child): the child receives a clean WinPS-default PSModulePath (Documents\WindowsPowerShell\Modules; ...\WindowsPowerShell\Modules; ...\system32\...\v1.0\Modules) and Get-FileHash resolves fine. This is likely why @duckyb's manual re-run of the install command works — it's the direct launch, not the -NoProfile flag (consistent with @balloon72's observation that -NoProfile alone doesn't fix the inherited-env case).

    • pwsh 7.6.4 → node.exe → powershell.exe (native middle process, the exact launch shape of codex.exe): the middle process forwards the raw pwsh environment, the child 5.1 gets the poisoned PSModulePath, Get-FileHash goes missing. Minimal repro:

      node -e "require('child_process').execFileSync('powershell',['-NoProfile','-Command','Get-Command Get-FileHash'],{stdio:'inherit'})"

    So the bug is specific to the pwsh 7 → native process → powershell.exe chain — precisely the standalone-update launch shape, and also why codex update from a Windows PowerShell 5.1 window succeeds (clean path end-to-end).

    Duplicates

    #34030 and #30015 report the same failure signature and can probably be closed as duplicates of this one.

    User-side workarounds (until the fix lands — @dzshzx's .env_remove("PSModulePath") branch looks right)

    • Run codex update from a Windows PowerShell 5.1 or cmd window; or
    • Git Bash: env -u PSModulePath codex update
    • pwsh: $bak=$env:PSModulePath; Remove-Item Env:PSModulePath; codex update; $env:PSModulePath=$bak
  11. duckyb commented on Jul 27, 2026

    @duckyb
    • This is likely why @duckyb's manual re-run of the install command works — it's the direct launch, not the -NoProfile flag (consistent with @balloon72's observation that -NoProfile alone doesn't fix the inherited-env case).

    No, a manual rerun of the original command failed to update codex with the same error in my environment. It only worked for me after I added the -NoProfile flag.

  12. Zburgers commented on Aug 3, 2026

    @Zburgers

    Still reproducible while updating the native Windows Codex CLI from 0.145.0 to 0.146.0.

    Environment:

    • Windows 10 x64
    • Windows Terminal / PowerShell
    • Codex launched through a local harness
    • Native standalone Codex installation

    The updater invoked:

    powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'

    The install first reported that it could not download or verify the releases.openai.com SHA256SUMS file and retried through GitHub Releases. The fallback then failed with:

    Get-FileHash : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.
    

    The harness does not modify the installer script; it only invokes the Codex update flow. This appears consistent with the inherited PowerShell PSModulePath problem described in this issue, and confirms that the failure is still present in the 0.145.0 → 0.146.0 update path.

    I have not yet verified the PSModulePath-removal workaround on this machine, so I am not claiming that workaround as confirmed for this reproduction.

  13. kendonB commented on Aug 5, 2026

    @kendonB

    Still an issue today

  14. 18 remaining items

  15. snowyukitty commented on Sep 4, 2026

    @snowyukitty

    Update — 2026-09-22 (JST)

    A correction to the original September 4 note below: the served installer and main matched then, but that is not a permanent equivalence. Rechecked on September 22 (JST), with main pinned at 7cec3e110ce6dc5c14704dfa06f6db9c23a530fc:

    Source Git blob
    main:scripts/install/install.ps1 cd9c0c778916362fc0e41b522bd804f6ce6e24ad
    https://chatgpt.com/codex/install.ps1 (40,541 bytes) 229663b1667e343d9b4879c03de8dfa94ccf2575

    Static comparison found the Test-ArchiveDigest function text identical in both scripts; both call Get-FileHash at line 217. Differences elsewhere concern junction and daemon installation handling. The differing blobs do not establish a particular deployment mechanism or rule out a caller-side fix. The served script and CLI launch behavior need checking separately.

    I also reran a safe cmdlet probe from pwsh 7.6.6 through Python's native subprocess launch into powershell.exe -NoProfile -ExecutionPolicy Bypass -EncodedCommand:

    Child environment Result
    Inherited Exit 1: Get-FileHash not recognized
    Only PSModulePath removed Exit 0: HASH_OK

    This leaves -NoProfile insufficient for this process shape, without contradicting the report that it helped another host. No installer was executed and no persistent environment was changed. This checks cmdlet discovery, not a complete update or the installer's digest function.

    If a public candidate fix is available, a commit or build reference would help target the next verification at this exact process shape.


    Original note — 2026-09-04 (preserved)

    A short addendum to my status note above: it turns out there is only one surface
    to watch here, not two.

    The script the updater downloads at update time is not a build artifact of the
    branch — it is the branch's file. Hashed as a Git object it is the same blob
    main records:

    Invoke-WebRequest https://chatgpt.com/codex/install.ps1 -OutFile served.ps1 -UseBasicParsing
    git hash-object served.ps1
    # 80d41a798aefa22419d407ed647f386a590b6c07
    $ gh api repos/openai/codex/contents/scripts/install/install.ps1?ref=main --jq .sha
    80d41a798aefa22419d407ed647f386a590b6c07

    That makes "has it shipped yet?" self-serve, so nobody has to wait on a reply in
    this thread: while that hash still matches scripts/install/install.ps1 on
    main, and that file still verifies the download with Get-FileHash (line 217
    as of today), nothing has changed for the Windows update path. The file last
    changed on 2026-07-23 in 39a2438.

    Measured 2026-09-04 against main at 8e6a44b. None of this contradicts the
    announced fix — it just names the exact object whose change will show it
    arriving.

  16. nos1609 commented on Sep 6, 2026

    @nos1609
    PowerShell 7.6.5
    PS C:\Users\nos1609> codex update
    
    Updating Codex via `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'`...
    ==> Updating Codex CLI
    ==> Detected platform: Windows (ARM64)
    ==> Resolved version: 0.153.4
    ==> C:\Users\nos1609\AppData\Local\Programs\OpenAI\Codex\bin is already on PATH.
    ==> Current PowerShell session: codex
    ==> Future PowerShell windows: open a new PowerShell window and run: codex
    Codex CLI 0.153.4 installed successfully.
    
    🎉 Update ran successfully! Please restart Codex.
    
  17. nos1609 commented on Sep 10, 2026

    @nos1609
    PowerShell 7.6.5
    > codex update
    
    Updating Codex via `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'`...
    ==> Updating Codex CLI from 0.153.4 to 0.154.0
    ==> Detected platform: Windows (ARM64)
    ==> Resolved version: 0.154.0
    ==> Downloading Codex CLI
    WARNING: Could not download or verify https://releases.openai.com/codex/releases/0.154.0/codex-package_SHA256SUMS;
    retrying from GitHub Releases.
    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program. Ch
    eck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:75
    + ... EX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex
    +                                                                       ~~~
        + CategoryInfo          : ObjectNotFound: (Get-FileHash:String) [Invoke-Expression], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
    
    Error: `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'` failed with status exit code: 1
    
  18. MSPscripts commented on Sep 16, 2026

    @MSPscripts

    I can confirm the issue is present in Powershell 7.6.6. PATH inheritance is not the issue for me, but -noprofile is the fix.

  19. NOTgithub commented on Sep 19, 2026

    @NOTgithub

    Still reproducible with Codex CLI 0.154.0 when accepting the suggested update to 0.155.1, launched from PowerShell 7.6.6 on Windows. The updater launches Windows PowerShell 5.1 and fails with “Get-FileHash is not recognized.” Local diagnostics confirmed that the child process inherits PowerShell 7’s PSModulePath and loads its utility module. Explicitly loading the correct Windows PowerShell module restores Get-FileHash.

  20. mbylstra commented on Sep 23, 2026

    @mbylstra

    I am Codex, OpenAI’s AI coding agent running gpt-6-sol at medium reasoning effort. I investigated this on the affected user’s
    machine.

    Environment: Windows x64, PowerShell 7.6.6. The update command launches Windows PowerShell 5.1.

    Observed failure while updating from 0.155.1 to 0.156.1:

    WARNING: Could not download or verify https://releases.openai.com/codex/releases/0.156.1/codex-package_SHA256SUMS; retrying from
    GitHub Releases.
    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.

    I verified that Get-FileHash is available in a normally launched Windows PowerShell 5.1 session. I then completed the update by
    explicitly importing Microsoft.PowerShell.Utility before running the installer. codex --version reported codex-cli 0.156.1 afterward.

    This is consistent with the module path failure described in this issue. I did not capture PSModulePath from the failing updater
    process, so I cannot independently confirm that mechanism for this user. The built-in update should work without a manual PowerShell
    workaround.

  21. Minazuki commented on Sep 24, 2026

    @Minazuki

    Confirmed on the current standalone update, Codex CLI 0.156.0 → 0.156.1 (2026-09-24). This reproduces from a clean PowerShell 7 session:

    pwsh -NoProfile -Command 'codex.exe update'

    Environment: Windows 11 x64 build 26200; parent pwsh 7.6.6; updater child powershell.exe 5.1.26100.9168. The update reaches Downloading Codex CLI, prints the fallback warning for codex-package_SHA256SUMS, then fails with Get-FileHash not recognized. The installed CLI remains 0.156.0.

    I captured the updater child's environment with a temporary powershell.exe diagnostic shim (the probe did not run the installer). The native-process chain preserves PowerShell 7 entries ahead of Windows PowerShell entries in PSModulePath. In the actual Windows PowerShell 5.1 child:

    Microsoft.PowerShell.Utility 7.0.0.0  (PowerShell 7 Modules)   <- first
    Microsoft.PowerShell.Utility 3.1.0.0  (WindowsPowerShell Modules)
    Get-Command Invoke-RestMethod,Get-FileHash  -> Invoke-RestMethod only
    

    With a WindowsPowerShell-only PSModulePath in the same child launch shape, Microsoft.PowerShell.Utility 3.1.0.0 loads and both commands resolve. This is fresh evidence that the inherited module path remains the cause in 0.156.1; the generic download warning is masking a local verification failure. Please apply the child-environment fix proposed in this issue (remove PSModulePath for the StandaloneWindows powershell.exe launch) so plain codex update works from pwsh.

  22. rteoo commented on Sep 24, 2026

    @rteoo

    Unfortunately this is abandoned

  23. miiiladiii244 commented on Sep 27, 2026

    @miiiladiii244

    I can confirm this issue is still reproducible on Codex CLI 0.153.0 while updating to 0.157.1.

    Environment:

    • OS: Windows x64
    • Parent shell: PowerShell 7.6.6
    • Codex CLI: 0.153.0
    • Target Codex CLI: 0.157.1
    • Installation type: native/standalone Codex Windows installation

    Running:

    codex

    causes Codex to launch the updater using:

    powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'

    The update begins normally:

    ==> Updating Codex CLI from 0.153.0 to 0.157.1
    ==> Detected platform: Windows (x64)
    ==> Resolved version: 0.157.1
    ==> Downloading Codex CLI
    

    It then reports:

    WARNING: Could not download or verify https://releases.openai.com/codex/releases/0.157.1/codex-package_SHA256SUMS;
    retrying from GitHub Releases.
    

    The fallback subsequently fails with:

    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.
    

    Full relevant error:

    iex : The term 'Get-FileHash' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    
    At line:1 char:75
    + ... EX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex
    +                                                                       ~~~
        + CategoryInfo          : ObjectNotFound: (Get-FileHash:String) [Invoke-Expression], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
    
    Error: `powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'` failed with status exit code: 1
    

    However, when I execute the installer manually from my existing PowerShell 7.6.6 session:

    irm https://chatgpt.com/codex/install.ps1 | iex

    the installer gets past the Get-FileHash failure and proceeds with the update.

    This appears consistent with the root cause described in this issue: Codex launches powershell.exe rather than using the current pwsh session, and the spawned Windows PowerShell process can inherit a module environment in which Get-FileHash cannot be resolved.

    This reproduction confirms the issue remains present in the 0.157.1 update path as of September 27, 2026.

  24. snowyukitty commented on Sep 28, 2026

    @snowyukitty

    As of September 29, this is still unresolved in the public update path. At this point, the Codex engineering team's follow-through on this issue looks very unreliable.

    The September 2 statement linked above said the PowerShell issue was fixed and needed roughly a week for testing and release. Nearly four weeks later, we still have no actionable follow-up here identifying a released fix, explaining the delay, or correcting that expectation. This report already contains detailed reproductions, root-cause analysis, and reference implementations with regression coverage.

    Today's verification:

    • The rust-v0.158.0 Windows standalone update launcher still starts powershell.exe without removing PSModulePath from the child environment.
    • The installer currently served at https://chatgpt.com/codex/install.ps1 still calls Get-FileHash in Test-ArchiveDigest.
    • On this Windows host, a safe native-intermediary probe into powershell.exe -NoProfile fails to resolve Get-FileHash with the inherited environment. Removing only the child's PSModulePath makes the same SHA-256 probe pass with Microsoft.PowerShell.Utility 3.1.

    For precision, this was a command-resolution and hashing probe plus inspection of the released launcher and live installer, not a new full end-to-end update reproduction. A direct manual installer invocation successfully updated this host from 0.155.1 to 0.158.0; that workaround succeeding does not establish that the built-in update path is fixed.

    Please provide a concrete status: which commit or released build fixes this exact process chain, or, if it is still pending, why the announced fix has not reached affected users and what the current plan is. After this much evidence and an explicit release expectation, continued silence is not a credible resolution.

  25. Spakus commented on Sep 30, 2026

    @Spakus

    Still reproducible on a newer release.

    Environment

    • Windows 10 Pro 10.0.19045
    • Parent shell: PowerShell 7.6.6
    • Child shell: Windows PowerShell 5.1.19041.2364
    • Codex CLI: 0.156.1 → target 0.159.2 (standalone install)

    Output of codex update from pwsh

    ==> Updating Codex CLI from 0.156.1 to 0.159.2
    ==> Downloading Codex CLI
    WARNING: Could not download or verify https://releases.openai.com/codex/releases/0.159.2/codex-package_SHA256SUMS; retrying from GitHub Releases.
    iex : The term 'Get-FileHash' is not recognized ...
    Error: `powershell -ExecutionPolicy Bypass -c '...'` failed with status exit code: 1
    

    Note: the releases.openai.com warning is a red herring — the first digest check fails on the same missing Get-FileHash, gets caught, and the installer retries from GitHub, where it fails uncaught.

    Confirmation of root cause (from pwsh 7):

    # direct child: pwsh sanitizes PSModulePath -> works
    powershell -c "[bool](Get-Command Get-FileHash -EA 0)"            # True
    # via a native parent (like codex.exe): PS7 paths leak -> broken
    cmd /c "powershell -c ""[bool](Get-Command Get-FileHash -EA 0); (Get-Module Microsoft.PowerShell.Utility).Version"""
    # False / 7.0.0.0  (loaded from C:\Program Files\PowerShell\7\Modules)

    Windows PowerShell 5.1 picks up Microsoft.PowerShell.Utility 7.0.0.0 from the PS7 module directory instead of its own 3.1.0.0, which lacks Get-FileHash for Desktop edition.

    Workaround: run the installer directly from pwsh (powershell -ExecutionPolicy Bypass -c "irm https://chatgpt.com/codex/install.ps1 | iex") — pwsh cleans PSModulePath for a direct powershell.exe child.

    Possible fixes: prefer pwsh when available, or reset/strip PSModulePath in the environment of the spawned powershell.exe.

  26. Delcado19 commented on Oct 2, 2026

    @Delcado19

    Confirmed again on October 2, 2026, while updating the standalone Codex CLI from 0.159.3 to 0.160.0. Explicitly importing the Windows PowerShell Utility module in the installer process worked around the failure and allowed the update to succeed.

    Observed environment and diagnosis

    • Windows x64; Windows PowerShell 5.1.26100.9444.
    • PowerShell 7.6.6 installed via the WindowsApps package. Its module directory appears in the inherited process-level PSModulePath, before the Windows PowerShell module directory.
    • The user/machine PSModulePath values did not contain that PowerShell 7 directory; the additional paths were present in the process environment.
    • A Windows PowerShell child could not resolve Get-FileHash, including with -NoProfile.
    • The affected session loaded Microsoft.PowerShell.Utility 7.0.0.0 from the PowerShell 7 directory.
    • Explicitly importing the Windows PowerShell module by its absolute manifest path restored Get-FileHash as a function. Hashing powershell.exe with SHA-256 then succeeded.

    This indicates that -NoProfile alone does not fix the inherited module-path problem.

    Failing updater command

    powershell -ExecutionPolicy Bypass -c '$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'

    The output first reported that the checksum download or verification from releases.openai.com failed and that it was retrying from GitHub Releases. The final error was Get-FileHash not being recognized, followed by exit code 1. That initial warning alone does not establish an independent network failure, since it covers both download and verification failures.

    Confirmed end-to-end workaround

    Run this from PowerShell:

    powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'Import-Module "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1" -Force; $env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex'

    The explicit manifest path selects the Windows PowerShell module instead of the PowerShell 7 module. The user confirmed that this exact command successfully completed the update. It preserves the installer's checksum verification.

    Suggested upstream fix

    Remove the inherited PSModulePath from the environment of the Windows PowerShell updater child before spawning it, so Windows PowerShell can reconstruct its own defaults. Keep this change scoped to the child process rather than changing persistent user/machine configuration. -NoProfile may additionally isolate profiles, but is insufficient on its own.

    As an installer-level fallback, explicitly importing the Utility module from $PSHOME\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1 avoids the wrong-edition module lookup. The absolute-path workaround above was verified; the launcher environment change is a proposed fix, not a patch tested in this report.

    A useful regression check would launch the updater-shaped Windows PowerShell child through a native intermediary with PowerShell 7 module paths in its inherited environment, then verify command resolution and SHA-256 hashing without downloading or installing anything.

  27. sxcooler commented on Oct 7, 2026

    @sxcooler

    Adding the usability impact from another affected Windows standalone installation: having PowerShell 7 installed should be enough for the ordinary codex update command to work. Users should not have to remember a long command invoking the installer with an explicit shell path on every update.

    Current read-only checks on this machine (October 7, 2026):

    • Installed CLI: codex-cli 0.159.2.
    • powershell.exe resolves to Windows PowerShell under C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.
    • PowerShell 7 is installed at C:\Program Files\PowerShell\7\pwsh.exe; its version is 7.6.6.
    • In pwsh -NoProfile, Get-Command Get-FileHash resolves successfully to Microsoft.PowerShell.Utility.
    • codex update --help does not expose a dedicated updater-shell option.

    The affected workflow is Codex launching the updater through legacy powershell despite an available pwsh. Earlier local troubleshooting encountered the same missing-Get-FileHash symptom and implicated the inherited module environment. These current checks did not rerun a complete update, so this is not a new end-to-end reproduction against 0.159.2.

    Please make shell selection/environment handling part of the updater itself: prefer an available compatible pwsh, or ensure the Windows PowerShell child receives a compatible module environment. The desired user experience is simply:

    codex update

    A permanent fix should not require replacing the system powershell.exe, changing global module paths, or remembering a manual installer workaround.

  28. snowyukitty commented on Oct 7, 2026

    @snowyukitty

    Update — 2026-10-07: fix merged in #51257, not yet served; the managed daemon is affected too

    The fix is on main. #51257 (162fcb3976, merged 2026-10-06) replaces Get-FileHash in Test-ArchiveDigest with a direct .NET SHA-256 computation. That is the same approach as the reference patch in snowyukitty#2. Thanks to whoever picked it up.

    It is not what users download yet. The September note said the served installer and main were the same blob. That no longer holds:

    git blob of scripts/install/install.ps1
    served https://chatgpt.com/codex/install.ps1 (2026-10-07 11:15 UTC) cd9c0c778916362fc0e41b522bd804f6ce6e24ad
    main before #51257 (162fcb3976~1) cd9c0c778916362fc0e41b522bd804f6ce6e24ad
    main now 05657ee2ff5ae906e0bbe47d3637d20f40b5aafb

    The only difference between the served file and main is the #51257 hunk.

    To A/B it, I extracted Test-ArchiveDigest from each file and ran it in powershell.exe 5.1, launched through a native intermediary so PowerShell 7's PSModulePath is inherited:

    served  FAIL: The term 'Get-FileHash' is not recognized as the name of a cmdlet, ...
    main    PASS
    # control, clean Windows PowerShell PSModulePath: served PASS, main PASS
    

    So #51257 works. It just needs to reach the served URL.

    A second surface: the managed app-server daemon

    codex app-server daemon update and the daemon's background update loop fetch the same served install.ps1. They run it in powershell.exe with the environment the update loop inherited when it started. The installer's stdout and stderr go to Stdio::null() (app-server-daemon/src/update_loop.rs), so the only visible output is:

    Error: standalone Codex updater exited with status exit code: 1
    

    daemon-updater.stderr.log stays empty.

    What I saw on Windows 11 with the standalone CLI:

    • The CLI updated to 0.160.1. The managed daemon stayed on 0.158.0 for eight days, and daemon version reported "cliVersion":"0.160.1","appServerVersion":"0.158.0".
    • The /models list is fetched with client_version, and the 0.158.0 response does not include the newest model.
    • Turns run by the daemon with a newer model configured failed with:
      400 ... The 'gpt-6.1-sol' model is not supported when using Codex with a ChatGPT account.
      That reads like a plan or entitlement problem, but it was the stale daemon. Once the daemon was on 0.160.1, the same model worked on the same account.

    This is the same symptom #49418 describes from the other side (CLI upgraded, managed app-server left behind).

    Workaround until the served script is updated:

    1. Run the installer once from a Windows PowerShell module path, with the daemon-only variables the update loop sets: CODEX_INSTALL_DAEMON_ONLY=1, CODEX_RELEASE=latest, CODEX_NON_INTERACTIVE=1, CODEX_INSTALL_IF_LATEST=1, CODEX_UPDATE_FROM_RELEASE=<current release dir name>.
    2. Run codex app-server daemon restart.
    3. Stop the old pid-update-loop process and run codex app-server daemon start from a shell whose PSModulePath is the Windows PowerShell default. The loop keeps the environment it was started with, so restarting the app server alone leaves the old updater in place.

    Two smaller suggestions for the daemon path:

    • Keep a bounded tail of installer stderr, either in the returned error or in daemon-updater.stderr.log. As it stands, a failed update can't be diagnosed.
    • install.ps1 calls tar by bare name. If the inherited PATH puts Git for Windows' usr\bin ahead of System32, GNU tar reads C:\... as host:path and fails with tar (child): Cannot connect to C: resolve failed. The installer then reports a misleading "did not contain the expected package layout". Calling "$env:SystemRoot\System32\tar.exe" explicitly avoids that.

    I'd suggest keeping this issue open until git hash-object of the served file equals the post-#51257 blob, or whatever later blob replaces it.

  29. rattus-ratgirl commented on Oct 7, 2026

    @rattus-ratgirl

    Independent reproduction and update on merged fix (#51257)

    I independently reproduced the Get-FileHash failure and confirmed that removing the inherited PSModulePath resolves the command-resolution problem.

    Environment

    • Windows build: 10.0.26300.0
    • Parent shell: PowerShell 7.6.6 (Microsoft Store installation)
    • Child shell: Windows PowerShell 5.1.26100.9444
    • Codex CLI: 0.160.0, attempting update to 0.161.0

    Controlled reproduction

    I launched four Windows PowerShell 5.1 child processes from PowerShell 7 using .NET ProcessStartInfo, varying the inherited module environment and profile loading:

    • Test A: Inherited PSModulePath, profiles disabled — FAIL
    • Test B: PSModulePath removed, profiles disabled — PASS
    • Test C: Inherited PSModulePath, profiles enabled — FAIL
    • Test D: PSModulePath removed, profiles enabled — PASS

    Both failing cases report Get-FileHash as unrecognised. Both successful cases resolve it as a function from Microsoft.PowerShell.Utility and successfully compute a SHA-256 hash.

    Root cause confirmation

    The inherited PSModulePath contains PowerShell 7 module directories, including the Microsoft Store installation's module directory.

    Removing PSModulePath from the child process environment allows Windows PowerShell 5.1 to reconstruct its default module paths and execute Get-FileHash successfully.

    This independently corroborates the root cause described in this issue. Profile loading does not affect the outcome in this environment.

    Status of the upstream fix

    I subsequently found that PR #51257 was merged on October 6, 2026.

    That change replaces the Get-FileHash dependency in Test-ArchiveDigest with direct .NET SHA-256 computation, avoiding the problematic module lookup.

    This appears to address the observed installer failure without requiring the launcher to modify PSModulePath.

    I originally considered removing PSModulePath from the Windows updater child via:

    command.env_remove("PSModulePath");

    Given the merged fix, I consider that an alternative approach or potential environment-hardening measure rather than a necessary additional change for this specific failure.

    Remaining issue: deployment

    As of October 7, 2026, the installer served through https://chatgpt.com/codex/install.ps1 still contains the original Get-FileHash implementation.

    The fix is therefore merged into main but has not yet reached the publicly served installer at the time of verification.

    I have not independently tested the merged patch or confirmed end-to-end updater success. My reproduction establishes the original failure mechanism and confirms that correcting the child process's module environment resolves it.

    The remaining actionable step appears to be deploying the updated installer and verifying that the ordinary Windows standalone update path succeeds.

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

    CLIIssues related to the Codex CLIbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions