Skip to content

Codex app doesn't open in WSL with bash #13488

Closed

Description

@kendonB

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

No About Codex

What subscription do you have?

Pro

What platform is your computer?

Windows 11

What issue are you seeing?

Image

What steps can reproduce the bug?

Open Codex, switch settings to WSL/bash throughout. Close Codex. Reopen Codex.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    appIssues related to the Codex desktop app
    on Mar 4, 2026
  2. added
    bugSomething isn't working
    windows-osIssues related to Codex on Windows systems
    on Mar 4, 2026
  3. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. mahdimessai commented on Mar 4, 2026

    @mahdimessai

    I found this temporary workaround until they fix this issue

    The idea is to grant Read + Execute on the specific Codex package.

    Run powershell as administrator.

    Get-ChildItem "C:\Program Files\WindowsApps" |
      Where-Object { $_.Name -like "OpenAI.Codex*" } |
      Select-Object Name, FullName

    Copy the folder path.

    $pkg = "C:\Program Files\WindowsApps\OpenAI.Codex_26.304.38.0_x64__2p2nqsd0c7..."

    Run:

    takeown /F "$pkg" /R /D Y

    then Run:

    icacls "$pkg" /grant "$($env:USERNAME):(OI)(CI)(RX)" /T

    Close codex app and re-open. Should work

  5. etraut-openai commented on Mar 4, 2026

    @etraut-openai
    Contributor

    Thanks for reporting. We understand the problem and are working on a fix.

  6. wbdb commented on Mar 4, 2026

    @wbdb

    PowerShell Script Fix:

    • Open PowerShell as administrator
    • Navigate to the script
    • .\Fix-CodexWindowsAppsAcl.ps1
    # Fix-CodexWindowsAppsAcl.ps1
    # Grants current user Read+Execute to the installed OpenAI.Codex WindowsApps package.
    # Run in an elevated PowerShell (Administrator).
    
    $ErrorActionPreference = "Stop"
    
    function Assert-Admin {
      $id = [Security.Principal.WindowsIdentity]::GetCurrent()
      $p  = New-Object Security.Principal.WindowsPrincipal($id)
      if (-not $p.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
        throw "Please run this script as Administrator."
      }
    }
    
    Assert-Admin
    
    $base = "C:\Program Files\WindowsApps"
    if (-not (Test-Path $base)) { throw "Path not found: $base" }
    
    # List matching packages
    $pkgs = Get-ChildItem $base -Directory |
      Where-Object { $_.Name -like "OpenAI.Codex*" } |
      Sort-Object LastWriteTime -Descending
    
    if (-not $pkgs -or $pkgs.Count -eq 0) {
      throw "No folders matching 'OpenAI.Codex*' found under $base"
    }
    
    Write-Host "Found Codex packages:" -ForegroundColor Cyan
    $pkgs | Select-Object Name, FullName, LastWriteTime | Format-Table -AutoSize
    
    # Pick newest
    $pkg = $pkgs[0].FullName
    Write-Host "`nUsing package:" -ForegroundColor Cyan
    Write-Host $pkg
    
    # Take ownership (recursive)
    Write-Host "`nRunning takeown..." -ForegroundColor Yellow
    # Note: On some localized Windows versions /D expects localized input. Omit /D to avoid 'Y' parse errors.
    & takeown /F "$pkg" /R | Out-Host
    
    # Ensure Administrators group has Full Control (often required before changing ACLs in WindowsApps)
    Write-Host "`nGranting Administrators Full Control (required for WindowsApps)..." -ForegroundColor Yellow
    & icacls "$pkg" /grant "Administrators:(OI)(CI)(F)" /T | Out-Host
    
    # Grant current user Read+Execute
    $user = $env:USERNAME
    Write-Host "`nGranting Read+Execute to '$user'..." -ForegroundColor Yellow
    & icacls "$pkg" /grant "${user}:(OI)(CI)(RX)" /T | Out-Host
    
    Write-Host "`nDone. Close Codex completely and reopen it." -ForegroundColor Green
    
  7. BWBrook commented on Mar 5, 2026

    @BWBrook

    It's now been resolved (update via Windows Store). I tested and it works.

  8. etraut-openai commented on Mar 5, 2026

    @etraut-openai
    Contributor

    Thanks for the confirmation!

  9. xvhuan commented on Mar 5, 2026

    @xvhuan
    Image

    I updated the Codex app via the Windows Store and tested again, but the issue still occurs on my side. The app-server still exits with the same error when WSL mode is enabled (permission denied when trying to execute the runtime under WindowsApps).

    Could you confirm which version contains the fix, or if there are any additional steps required after updating? I’m currently unable to start Codex when WSL execution is enabled.

  10. TheBeems commented on Mar 5, 2026

    @TheBeems

    It's now been resolved (update via Windows Store). I tested and it works.

    Which version should we have? My codex app has been updated to version 26.304.1528.0, but I get the following error:

    Codex app-server exited unexpectedly (code=126, signal=null). Most recent error: /usr/bin/bash: line 1: /mnt/c/Users/beems/.codex/bin/wsl/codex: Success

    Edit 1:
    I tried also with deleting the .codex folder in my user profile to start clean. But when setting it to use wsl, it give the above error again.

    Edit 2:
    I did some debugging with Chat. It came to the conclusion I was running WSL as arm64 and that triggered the error. The codex file at .codex/bin/wsl/codex shows ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped.

    Can others confirm that it isn't working and they are on arm64 WSL?

  11. illgitthat commented on Mar 5, 2026

    @illgitthat

    @TheBeems @xvhuan Since the issue was closed out, open a new issue if you are still experiencing this.

  12. peckomingo commented on Mar 5, 2026

    @peckomingo

    I am also on WSL and arm64 and have the same problem.

  13. Mohitxxx commented on Mar 6, 2026

    @Mohitxxx

    An error has occurred
    Codex crashed with the following error:

    Codex app-server exited unexpectedly (code=3221225781, signal=null).
    Most recent error: None
    Some things to try:

    Check your config.toml for invalid settings
    Check your settings to disable running in WSL if you are seeing compatibility issues
    Try downloading a different version of the extension

    Any help...

  14. MertCtn commented on Mar 8, 2026

    @MertCtn

    It's now been resolved (update via Windows Store). I tested and it works.

    No it didn't fixed

    Image
  15. wbdb commented on Mar 9, 2026

    @wbdb

    @Mohitxxx @MertCtn Looks like a new bug. Best to create a separate issue. Everything is running smoothly here. This was a permissions error. Something seems to be wrong with Bash on your end.

    To prevent permission error on your end check my script: #13488 (comment) If the error persists after that, it is a new problem.

  16. TheBeems commented on Mar 9, 2026

    @TheBeems

    I created a new issue for machines on arm cpu's: #13565

    But I assume it has very low priority. Is the codex app open source as well? So we can compile the app ourselves?

  17. benchan111999-cmd commented on Apr 27, 2026

    @benchan111999-cmd

    These are the steps from Claude Sonnet 4.6 in English, and it helped me to solve the problem:

    Root Cause

    When Docker Desktop is installed, the WSL default distribution may be set to docker-desktop or docker-desktop-data. These are Docker's internal distributions and do not contain a full Linux environment (no /usr/bin/bash). Codex reads the WSL default distribution and tries to execute within it, resulting in this error.

    Diagnostic Step

    Run the following in PowerShell to check your current WSL status:

    wsl -l -v

    If the output looks like this:

      NAME                   STATE           VERSION
    * docker-desktop         Running         2
      docker-desktop-data    Running         2
      Ubuntu                 Stopped         2
    

    The * next to docker-desktop confirms this is the issue.

    Fix Options

    Fix 1: Change the WSL Default Distribution (Most Effective)

    wsl --set-default Ubuntu

    If your Ubuntu distribution has a different name (e.g. Ubuntu-22.04), replace accordingly. Then restart the Codex app.

    Fix 2: Make Sure Ubuntu is Running on WSL2

    If Ubuntu is still on WSL1, upgrade it:

    wsl --set-version Ubuntu 2

    Then run Fix 1 again.

    Fix 3: If No Linux Distribution is Installed

    If wsl -l -v only shows docker-desktop entries, you have no Ubuntu installed:

    wsl --install

    This installs Ubuntu as the default distribution. Restart your PC after.

    Fix 4 (Temporary Workaround): Edit the Config File Manually

    If none of the above resolves it immediately:

    1. Open %USERPROFILE%\.codex\.codex-global-state.json
    2. Set runCodexInWindowsSubsystemForLinux to false
    3. Restart Codex, then go to Settings and switch back to WSL mode

    Recommended Order

    1. Run wsl -l -v to confirm the issue
    2. Run wsl --set-default Ubuntu (or the correct distribution name)
    3. Restart Codex

    This approach directly addresses the root cause, unlike the permission fixes you previously attempted.

    這些是來自 Claude Sonnet 4.6 的步驟(英文版),它幫助我解決了問題:

    這個問題的核心在於:Codex 嘗試在 docker-desktop 這個 WSL 發行版中運行,而非真正的 Linux 發行版(如 Ubuntu),因此找不到 /usr/bin/bash。 這是一個已知的 WSL 預設發行版設定問題。

    問題根源

    當你安裝了 Docker Desktop 後,WSL 的預設發行版可能被設定為 docker-desktop 或 docker-desktop-data,而這些是 Docker 的內部發行版,並不包含完整的 Linux 環境(沒有 /usr/bin/bash)。Codex 讀取 WSL 預設發行版並嘗試在其中執行,結果就出現此錯誤 。 github

    診斷步驟

    先在 PowerShell 執行以下指令,確認目前 WSL 狀態:

    wsl -l -v

    如果輸出類似:

      NAME                   STATE           VERSION
    * docker-desktop         Running         2
      docker-desktop-data    Running         2
      Ubuntu                 Stopped         2
    

    看到 * 標記在 docker-desktop 旁邊,就確認是這個問題。

    修復方案

    方案 1:更改 WSL 預設發行版(最根本的修復)

    wsl --set-default Ubuntu

    如果你的 Ubuntu 發行版名稱不同(例如 Ubuntu-22.04),請用正確名稱替換 。改完後重新啟動 Codex 即可。 [stackoverflow](https://stackoverflow.com/questions/72483632/ubuntu-error-the-command-docker-could-not-be-found-in-this-wsl-2-distro)

    方案 2:確認 Ubuntu 為 WSL2 版本

    如果 Ubuntu 發行版仍是 WSL1,需要升級:

    wsl --set-version Ubuntu 2

    完成後再執行方案 1 。 [dev](https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9/comments)

    方案 3:如果未安裝任何 Linux 發行版

    若 wsl -l -v 只顯示 docker-desktop 系列,代表你尚未安裝 Ubuntu:

    wsl --install

    這會安裝 Ubuntu 作為預設發行版,完成後重啟電腦 。 [developers.openai](https://developers.openai.com/codex/windows)

    方案 4(臨時 Workaround):手動修改設定檔

    如果以上都無法立即解決,可暫時避免 app 無法啟動的問題 : [x](https://x.com/dkundel/status/2029263781558403504)

    1. 開啟 %USERPROFILE%\.codex\.codex-global-state.json
    2. 將 runCodexInWindowsSubsystemForLinux 改為 false
    3. 重新啟動 Codex,進入設定後再重新切換回 WSL 模式

    建議執行順序

    1. 先跑 wsl -l -v 確認問題
    2. 執行 wsl --set-default Ubuntu(或正確的發行版名稱)
    3. 重新啟動 Codex

    這個步驟比之前嘗試的權限修復更直接針對根本原因。

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

    appIssues related to the Codex desktop appbugSomething 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