Fix Codex Windows "Oops" After Adding a Second Folder

Fix Codex Windows "Oops" After Adding a Second Folder

Aident AI

Two sculptural color fields split at an orange seam beside one calm cyan oval.

Fix Codex Windows "Oops" After Adding a Second Folder

If Codex Desktop on Windows became stuck on "Oops, an error has occurred" immediately after you added a second folder, fully quit the app and update it first. If the error survives the update, back up both Codex global-state files and remove only the newly added path from the affected project's rootPaths array in each copy. Keep the original root, validate both JSON files, and reopen Codex.

Do not delete the entire .codex directory. Multiple July 24-27, 2026 reports show that the smaller edit can restore the app while preserving chats, authentication, projects, and unrelated settings. OpenAI has not published a universal recovery procedure, and reports about build 26.721.41059 conflict, so treat this as a careful workaround for the exact multi-folder failure.

Prerequisites

Before changing local state:

  • confirm the failure began when a second folder was added to one Codex project;

  • record the app version from Settings > About if the UI still opens;

  • close active Codex tasks and save unrelated work;

  • use Windows PowerShell under your normal account;

  • keep both backup files until Codex has launched successfully more than once.

This guide applies to Codex or ChatGPT Desktop on Windows. It does not apply to a repository that merely lacks Git metadata, a WSL Git detection error, or a general service outage.

Step 1: Confirm the Multi-Folder Failure

The reported pattern is specific:

  1. A project works with one local folder.

  2. You add a second folder to that project.

  3. Codex immediately shows "Oops, an error has occurred".

  4. Try again, restarting, or reinstalling does not recover the UI.

  5. The error returns because the saved project still contains multiple root paths.

Several reports also recorded this renderer error:

ReferenceError: process is not defined
name=AppRoutes

You do not need to find that log entry before using the recovery. The timing of the failure is the safer discriminator. If the app failed before you changed project folders, stop here and use a guide for that exact symptom instead.

Step 2: Update With the App Fully Closed

First try the least invasive path:

  1. Fully quit Codex or ChatGPT Desktop.

  2. Open Microsoft Store and install the latest available app update.

  3. Reopen Codex.

  4. If it starts, keep each project to one folder until the issue is confirmed fixed on your build.

One July 25 report said build 26.721.41059 no longer crashed when a second folder was added. Another report reproduced the same failure on that build, and a July 27 comment described it as fixed without identifying a newer version. Updating is worth trying, but the evidence does not support calling one build universally safe.

If the app still opens to the same error, close it again before editing state.

Step 3: Verify Codex Is Fully Stopped

In PowerShell, run:

Get-Process ChatGPT, Codex -ErrorAction SilentlyContinue |
  Select-Object Id, ProcessName, StartTime

Expected result: no process is returned. If a Codex or ChatGPT process remains, close it from Task Manager and rerun the check.

Do not edit the files while the app is running. Codex can rewrite global state on exit and undo the repair.

Step 4: Back Up Both Global-State Files

Run:

$codexState = Join-Path $env:USERPROFILE ".codex"
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"

Copy-Item `
  "$codexState\.codex-global-state.json" `
  "$codexState\.codex-global-state.json.$stamp.backup"

Copy-Item `
  "$codexState\.codex-global-state.json.bak" `
  "$codexState\.codex-global-state.json.bak.$stamp.backup"

Confirm the backups exist:

Get-ChildItem "$codexState\*.backup" |
  Sort-Object LastWriteTime -Descending |
  Select-Object -First 2 Name, Length, LastWriteTime

Expected result: two recent, non-empty backup files. If either source file is missing, stop rather than creating a replacement from memory.

Step 5: Remove Only the Second Root

Open the primary state file:

notepad "$codexState\.codex-global-state.json"

Find local-projects, then locate the affected project. Its shape should resemble:

{
  "local-projects": {
    "<project-id>": {
      "name": "<project-name>",
      "rootPaths": ["C:\\path\\to\\original-repository", "C:\\path\\to\\folder-added-last"]
    }
  }
}

Change only that project's rootPaths array to keep its original first folder:

"rootPaths": [
  "C:\\path\\to\\original-repository"
]

Save the file. Repeat the same targeted edit in the fallback copy:

notepad "$codexState\.codex-global-state.json.bak"

Do not change project IDs, names, chat records, authentication, SQLite files, skills, or repository contents. Do not clear all of .codex; that broader reset can remove unrelated local UI and project state.

Step 6: Validate Both Files Before Relaunch

Run:

& {
  $ErrorActionPreference = "Stop"
  @(
    "$codexState\.codex-global-state.json"
    "$codexState\.codex-global-state.json.bak"
  ) | ForEach-Object {
    Get-Content -Raw $_ | ConvertFrom-Json | Out-Null
  }
  "Both state files contain valid JSON."
}

Expected result:

Both state files contain valid JSON

If PowerShell reports a JSON error, do not open Codex. Restore both timestamped backups, then repeat the edit without changing commas, braces, or escaping.

Step 7: Relaunch and Verify Recovery

Open Codex and check:

  1. The home screen loads instead of the error boundary.

  2. Your existing chats remain visible.

  3. The affected project opens with its original folder.

  4. A short read-only task can inspect that folder.

  5. Closing and reopening the app once does not restore the bad second root.

Keep the backup files until these checks pass. Use separate single-folder projects if you need both repositories in Codex.

Common Failure Modes

What you see

Likely meaning

Safe next step

The error began before any folder change

This is probably a different Codex failure

Stop and diagnose the original trigger

The app rewrites the second root after editing

Codex was still running or only one state copy was changed

Quit fully, restore the backups, and edit both copies

ConvertFrom-Json reports an error

The manual edit broke JSON syntax

Restore both backups before trying again

One folder remains but the error persists

Extra migration state or another bug may be active

Restore the backups and add sanitized evidence to the matching issue

Deleting all of .codex opens the app

Corrupt state was removed together with unrelated local data

Keep the backup; prefer the targeted rootPaths repair next time

A second folder works on your updated build

Your build may contain a partial or complete fix

Do not assume every Windows configuration is fixed

Why the Targeted Repair Works

The affected project persists its folders in rootPaths, so restarting or reinstalling can reload the same multi-root state. Reducing only the affected array to one root removes the reproducible trigger without erasing the rest of Codex's local data.

One detailed issue analysis traced build 26.721.3996.0 to a Windows path being passed through a POSIX relative-path comparison. With two roots, the renderer reportedly reaches process.cwd() even though process is unavailable, which throws during route rendering. A single root avoids that comparison. This analysis fits the reports and the observed workaround, but it is community reverse engineering rather than an OpenAI root-cause statement.

Test One External Action After Recovery

Once Codex is stable, verify the repaired app with a bounded read-only task instead of another multi-folder experiment. In Codex, paste:

Follow https://aident.ai/SETUP.md

Then ask:

Check my Aident Loadout account and Vault status.
Find one connected read-only GitHub Action that can search issues.
Inspect its current schema, execute it once for open Codex Windows issues, and stop.
Do not edit files or ask me to paste a provider key

Expected result: Codex inspects one live Action schema, returns one read-only issue result, makes no repository change, and remains usable after restart.

Use Aident Loadout to run one connected Action. Measure success as one verified external result, zero pasted secrets, and zero local file changes.

Sources

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.