codex - 💡(How to fix) Fix VS Code/WSL creates a persistent empty .codex file in workspace root [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17109Fetched 2026-04-09 08:02:16
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3closed ×1commented ×1

Root Cause

Deletion behavior seems context-dependent:

  • in a normal shell, rm .codex prompts because the file is write-protected
  • in the Codex execution environment, deletion may fail with: rm: cannot remove '.codex': Device or resource busy

Code Example

?? .codex

---

-r--r--r-- 1 <user> <group> 0 Apr  8 11:37 .codex

---

.codex: empty

---

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
RAW_BUFFERClick to expand / collapse

What version of the IDE extension are you using?

26.325.31654

What subscription do you have?

Plus

Which IDE are you using?

VS Code

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What issue are you seeing?

When using Codex in VS Code on a Git repository opened through WSL2, an empty .codex file is created in the workspace root.

Observed behavior:

  • .codex appears as an untracked file in git status
  • the file is empty (0 bytes)
  • the file can reappear while actively using Codex
  • deleting it does not reliably solve the issue permanently

Deletion behavior seems context-dependent:

  • in a normal shell, rm .codex prompts because the file is write-protected
  • in the Codex execution environment, deletion may fail with: rm: cannot remove '.codex': Device or resource busy

Relevant command output:

git status --short

?? .codex

ls -l .codex

-r--r--r-- 1 <user> <group> 0 Apr  8 11:37 .codex

file .codex

.codex: empty

uname -mprs

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

I also restarted both VS Code and WSL during debugging, but the file still reappeared during later Codex usage.

The project itself does not use .codex.

What steps can reproduce the bug?

  1. Open a Git repository in VS Code through Remote - WSL / WSL2
  2. Start using Codex in that workspace
  3. Let Codex inspect or edit the repository
  4. Check the repo root
  5. Run git status --short
  6. Observe that .codex appears as an untracked file
  7. Try deleting the file with rm .codex
  8. Continue using Codex and observe that the file may reappear

Additional note:

  • in some contexts, deleting the file from the Codex execution environment fails with Device or resource busy
  • in a normal shell, deletion prompts because the file is write-protected

What is the expected behavior?

Codex should not create an untracked file in the repository root.

If such a file is needed internally, it should ideally be stored outside the project root or handled in a way that does not pollute git status.

Additional information

No response

extent analysis

TL;DR

The issue can be mitigated by configuring Codex to store its internal files outside the project root or by adding the .codex file to the project's .gitignore file.

Guidance

  • Investigate Codex configuration options to see if there's a way to specify a different location for its internal files, potentially avoiding the creation of .codex in the repository root.
  • Add .codex to the project's .gitignore file to prevent it from appearing in git status as an untracked file, which might help in managing the project's Git repository.
  • Verify the file system permissions and ownership of the repository root to ensure that Codex has the necessary permissions to create and manage its files without causing conflicts.
  • Consider reporting this issue to the Codex or VS Code teams, as the behavior of creating an untracked file in the repository root might be unintended and worthy of further investigation.

Example

echo ".codex" >> .gitignore

This command adds .codex to the project's .gitignore file, which tells Git to ignore this file.

Notes

The exact cause of the issue is unclear, but it seems related to how Codex interacts with the file system in a WSL2 environment. The provided steps to reproduce the bug are helpful for further debugging.

Recommendation

Apply workaround: Adding .codex to .gitignore is a straightforward way to mitigate the issue's impact on Git repository management, even if it doesn't address the root cause of the file creation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING