Codex Desktop 26.609.41114 repeatedly exhausts syspolicyd and cannot relaunch until reboot

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

What version of the Codex App are you using?

Codex Desktop 26.609.41114 (CFBundleVersion 3888)

Code signing details:

Identifier=com.openai.codex
CDHash=f669521b379f32fe57c858c7d806d14cb30d721f
Timestamp=Jun 13, 2026 at 6:54:30 AM
TeamIdentifier=2DC432GLL2
Runtime Version=26.2.0
Sealed Resources version=2 rules=13 files=7929

What subscription do you have?

Not relevant to this local macOS app startup / system policy issue.

What platform is your computer?

macOS 26.5.1 (25F80)
Darwin 25.5.0 RELEASE_ARM64_T6050 arm64
Apple Silicon

What issue are you seeing?

Codex Desktop 26.609.41114 repeatedly drives macOS syspolicyd into a high CPU / high memory / file-descriptor growth loop. Once this happens, Gatekeeper assessment starts failing globally, and other apps such as Typora cannot be launched until the machine is rebooted.

This looks related to existing syspolicyd / Too many open files / code_sign_clone reports, but I am opening a separate issue because my current reproduction has a specific loop:

  1. Reboot macOS.
  2. Launch Codex Desktop.
  3. syspolicyd CPU and FD count grow rapidly.
  4. Quit Codex Desktop: syspolicyd CPU/FD growth stops.
  5. Try to launch Codex Desktop again: it fails to open.
  6. Reboot macOS: Codex Desktop opens again, then the same syspolicyd runaway loop starts again.

During the failure, spctl fails for unrelated apps:

/Applications/Typora.app: Too many open files
/Applications/Codex.app: Too many open files

After restarting syspolicyd, spctl temporarily recovers:

/Applications/Typora.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: Abner Lee (9HWK5273G4)

/Applications/Codex.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: OpenAI OpCo, LLC (2DC432GLL2)

But while Codex Desktop continues running, syspolicyd starts growing again.

What steps can reproduce the bug?

On this machine:

  1. Reboot macOS.
  2. Open /Applications/Codex.app.
  3. Observe syspolicyd:
ps -p "$(pgrep -x syspolicyd)" -o pid,%cpu,%mem,etime,command
sudo lsof -n -p "$(pgrep -x syspolicyd)" | wc -l
sudo lsof -n -p "$(pgrep -x syspolicyd)" \
  | awk 'NR>1 {name=$9; for(i=10;i<=NF;i++) name=name " " $i; c[name]++} END{for(n in c) print c[n], n}' \
  | sort -nr | head

Observed results:

PID    %CPU  %MEM  ELAPSED  COMMAND
273    114.5 0.8   04:59    /usr/libexec/syspolicyd

161987 /Applications/Codex.app/Contents/MacOS/Codex

In a separate run, after restarting syspolicyd, the FD count quickly grew again while Codex Desktop was still running:

19:27:38  syspolicyd 127.3% CPU   31283 open files
19:27:49  syspolicyd 184.9% CPU   43360 open files
19:28:00  syspolicyd 200.2% CPU   58374 open files
19:28:14  syspolicyd 204.5% CPU   76565 open files
19:28:31  syspolicyd 208.9% CPU   88692 open files

The open files are overwhelmingly the Codex main executable:

111533 /Applications/Codex.app/Contents/MacOS/Codex

sample syspolicyd shows work concentrated in the macOS system policy / YARA / code-signing path:

Dispatch Thread Soft Limit: 90 reached
DispatchQueue_176: com.apple.security.syspolicy.yara
SecStaticCodeCreateWithPath
Security::CodeSigning::DiskRep::bestGuess
Security::CodeSigning::SingleDiskRep::fd()
Security::UnixPlusPlus::FileDesc::open

I also see a temporary Codex code-sign clone directory while the problem is happening:

/var/folders/.../X/com.openai.codex.code_sign_clone
1.2G

/var/folders/.../X/com.openai.codex.code_sign_clone/code_sign_clone.<random>/Codex.app.bundle
1.2G

This directory contains a full Codex.app.bundle, including:

Contents/_CodeSignature
Contents/MacOS
Contents/Resources
Contents/Frameworks
Contents/embedded.provisionprofile
Contents/Info.plist

What is the expected behavior?

Codex Desktop should not repeatedly trigger macOS syspolicyd / Gatekeeper / XProtect / YARA assessment of its own main executable in a way that causes CPU, memory, and FD count to grow without bound.

Quitting and relaunching Codex Desktop should not require rebooting macOS.

Unrelated apps should not fail Gatekeeper assessment with Too many open files.

Additional information

This began after the Codex Desktop app updated to 26.609.41114 on June 13, 2026. I initially noticed it after running brew update / brew upgrade, but local evidence points to the Codex Desktop app rather than the Homebrew CLI codex cask:

  • Homebrew codex cask is the terminal binary (0.139.0) under /opt/homebrew/bin/codex.
  • The runaway syspolicyd FD aggregation points at /Applications/Codex.app/Contents/MacOS/Codex.
  • /Applications/Codex.app is signed and notarized.

Related issues I found:

  • openai/codex#27662
  • openai/codex#25719
  • openai/codex#27536
  • openai/codex#25243
  • openai/codex#26341
  • openai/codex#16767

I am opening this separately because the specific behavior here is:

  • 26.609.41114
  • quitting Codex Desktop stops syspolicyd CPU/FD growth
  • relaunching Codex Desktop fails until reboot
  • reboot allows one launch, then the runaway loop returns
  • code_sign_clone appears during the failure

View original on GitHub ↗

12 Comments

github-actions[bot] contributor · 1 month ago

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

  • #27662
  • #27136
  • #26795

Powered by Codex Action

771523908 · 1 month ago

Additional data point from another macOS 26.5.1 machine, with a slightly different user-visible failure mode: the Codex/syspolicyd FD buildup caused an unrelated signed Electron app (Claude Desktop) to fail at dyld library validation.

Environment

macOS: 26.5.1 (25F80)
Darwin: 25.5.0 RELEASE_ARM64_T6020 arm64
Hardware: Mac14,6, Apple M2 Max, 96 GB RAM
Codex Desktop: 26.609.41114 (CFBundleVersion 3888)
ChromiumBaseVersion: 149.0.7827.54
Bundled CLI: codex-cli 0.140.0-alpha.2
Claude Desktop involved as unrelated affected app: 1.12603.1, bundle id com.anthropic.claudefordesktop, Team ID Q6L2SF6YDW
SIP: enabled

User-visible symptom

Launching Claude Desktop repeatedly crashed immediately. The Claude crash report showed dyld refusing to load its bundled Electron Framework:

Termination Reason: Namespace DYLD, Code 1, Library missing
Library not loaded: @rpath/Electron Framework.framework/Electron Framework
Referenced from: /Applications/Claude.app/Contents/MacOS/Claude
Reason: tried: '/Applications/Claude.app/Contents/Frameworks/Electron Framework.framework/Electron Framework'
(code signature in ... '/Applications/Claude.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework'
not valid for use in process: library load denied by system policy)

Claude itself did not appear corrupt:

codesign --verify --deep --strict --verbose=4 /Applications/Claude.app
/Applications/Claude.app: valid on disk
/Applications/Claude.app: satisfies its Designated Requirement

syspolicy_check distribution /Applications/Claude.app
App passed all pre-distribution checks and is ready for distribution.

Realtime syspolicyd evidence during failed Claude launch

While launching Claude in the bad state, a realtime log stream from syspolicyd showed EMFILE/YARA failures followed by malware rejection. Representative lines:

syspolicyd[...] failed to read /Library/Preferences/Logging/com.apple.diagnosticd.filter.plist: [24: Too many open files]
syspolicyd[...] [com.apple.securityd:security_exception] UNIX error exception: 24
syspolicyd[...] Failed to generate SecStaticCode for <private> error: 100024
syspolicyd[...] Failed to open main executable (<private>) for hashing: Too many open files
syspolicyd[...] YARA scan failed with error: 3 Error Domain=com.apple.security.syspolicy.yara Code=3 ...
syspolicyd[...] Error performing Yara scan: Error Domain=com.apple.security.syspolicy.yara Code=3 ...
syspolicyd[...] Terminating process due to Malware rejection: <pid>, <private>

This matches the pattern in this issue: system policy assessment fails because syspolicyd is unhealthy, then unrelated apps are rejected.

Not global FD exhaustion

At the same time, the system-wide file table was not close to full:

kern.num_files: ~28,000
kern.maxfiles: 491,520
kern.maxfilesperproc: 245,760

Evidence pointing at Codex executable handles inside syspolicyd

With root privileges, lsof on syspolicyd showed almost all open descriptors pointing to the Codex app main executable:

2537 /Applications/Codex.app/Contents/MacOS/Codex
   3 /dev/null
   2 /private/var/db/SystemPolicyConfiguration/Tickets-shm
   2 /private/var/db/SystemPolicyConfiguration/KextPolicy-shm
   2 /private/var/db/SystemPolicyConfiguration/ExecPolicy-shm
   ... other entries mostly 1 each ...

Total descriptors observed in that sample were about 2574, with 2537 of them being /Applications/Codex.app/Contents/MacOS/Codex.

Behavior after restarting syspolicyd

launchctl kickstart -k system/com.apple.security.syspolicy was blocked by SIP:

Could not kickstart service "com.apple.security.syspolicy": 150: Operation not permitted while System Integrity Protection is engaged

But sudo killall syspolicyd let launchd restart it and immediately fixed Claude launch. After that:

Claude process stayed running
No new Claude .ips crash report was created
No new recent syspolicyd YARA / Too many open files / Malware rejection logs appeared

I then measured syspolicyd again. Immediately after restart:

codex_fd_count=221-256
syspolicyd total fd count ~=292

During continued Codex desktop activity and diagnostic commands from inside the Codex app, the count climbed again:

codex_fd_count=1900, total_fd_count=1936
codex_fd_count=1772, total_fd_count=1808
codex_fd_count=1667, total_fd_count=1703
codex_fd_count=1924, total_fd_count=1961
codex_fd_count=2079, total_fd_count=2115
codex_fd_count=2238, total_fd_count=2306

As a small control, running /bin/true 20 times did not change the Codex fd count in syspolicyd:

before=2537
after=2537

So the growth does not appear to be caused by arbitrary subprocess launches alone. It appears tied to Codex Desktop / this Codex session repeatedly causing macOS policy assessment of /Applications/Codex.app/Contents/MacOS/Codex.

Why this may help narrow the bug

This data point shows the same Codex fd accumulation as the main issue, but with a downstream failure in an unrelated signed app:

  1. syspolicyd accumulates thousands of duplicate read descriptors for /Applications/Codex.app/Contents/MacOS/Codex.
  2. An unrelated app launch requires dyld/library validation.
  3. syspolicyd hits EMFILE while hashing/scanning.
  4. YARA scan fails.
  5. macOS reports library load denied by system policy, causing the unrelated app to crash.

I am intentionally not attaching the full Codex session transcript or raw process dumps because they can contain local paths, command arguments, and environment values. The excerpts above are sanitized except for public app bundle paths and version/build identifiers.

GitZhangChi · 1 month ago

Additional data point from another macOS 26.5.1 Apple Silicon machine. This looks like the same macOS policy / signing / syspolicyd failure class described in this issue, but in my case it reproduces from a fresh official DMG install and the first visible failure is AMFI rejecting the main Codex executable.

Environment

Model Name: MacBook Pro
Product name: MacBook Pro (16-inch, Nov 2023)
Model Identifier: Mac15,11
Chip: Apple M3 Max
CPU cores: 14 total (10 performance + 4 efficiency)
Memory: 36 GB
Architecture: arm64
macOS: 26.5.1 (25F80)
Darwin: 25.5.0 RELEASE_ARM64_T6031
SIP: enabled
Codex Desktop: 26.609.41114
CFBundleVersion: 3888
Bundle ID: com.openai.codex
DMG path: official Codex.dmg
Install path: /Applications/Codex.app

Serial number, hardware UUID, and UDID are intentionally omitted.

DMG and signing checks

The DMG itself verifies as valid:

hdiutil verify Codex.dmg
checksum of "Codex.dmg" is VALID

After copying Codex.app to /Applications, the app appears valid to the usual signing/Gatekeeper checks:

codesign --verify --deep --strict --verbose=2 /Applications/Codex.app
/Applications/Codex.app: valid on disk
/Applications/Codex.app: satisfies its Designated Requirement

spctl --assess --type execute --verbose=4 /Applications/Codex.app
/Applications/Codex.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: OpenAI OpCo, LLC (2DC432GLL2)

Launch failure

Launching the app fails:

open -a /Applications/Codex.app
The application /Applications/Codex.app cannot be opened for an unexpected reason,
error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed."
NSUnderlyingError=NSPOSIXErrorDomain Code=163 "Launchd job spawn failed"

Unified logs show AMFI rejecting the main executable:

/Applications/Codex.app/Contents/MacOS/Codex not valid:
Error Domain=AppleMobileFileIntegrityError Code=-400 "An unknown error was encountered"

AMFI: When validating /Applications/Codex.app/Contents/MacOS/Codex:
Code has restricted entitlements, but the validation of its code signature failed.
Unsatisfied Entitlements:

mac_vnode_check_signature: /Applications/Codex.app/Contents/MacOS/Codex:
code signature validation failed fatally

ASP: Security policy would not allow process: /Applications/Codex.app/Contents/MacOS/Codex

Provisioning / entitlement mismatch

The embedded provisioning profile contains only:

com.apple.application-identifier = 2DC432GLL2.com.openai.codex
com.apple.developer.team-identifier = 2DC432GLL2
keychain-access-groups = [2DC432GLL2.*]

But the app signature declares additional restricted entitlements, including:

com.apple.security.application-groups = [2DC432GLL2.com.openai.sky.CUAService]
keychain-access-groups = [2DC432GLL2.*, 2DC432GLL2.com.openai.shared]

So although codesign / spctl accept the bundle, AMFI rejects it at process launch because the restricted entitlements do not appear to be covered by the embedded provisioning profile.

As a local diagnostic only, I tried ad-hoc re-signing the copied /Applications/Codex.app. That got past the initial AMFI rejection, but the app then crashed because the main process and bundled framework signatures no longer matched:

dlopen ... Codex Framework.framework ... not valid for use in process:
mapping process and mapped file (non-platform) have different Team IDs

This points away from quarantine or a local drag/install mistake and toward the same signing/provisioning/system-policy layer discussed in this issue.

syspolicyd handle growth

One more local observation from the same machine: while Codex Desktop GUI was present/running, syspolicyd kept accumulating duplicate file descriptors for the Codex main executable.

Observed handle growth:

syspolicyd open handles: 19620 -> 34863
Most entries repeatedly point to: /Applications/Codex.app/Contents/MacOS/Codex

This matches the behavior described in this issue: Codex Desktop appears to continuously drag macOS system policy / security validation through repeated opens of its own main executable. I am stopping/removing the GUI app locally for now and keeping only the CLI to avoid further impact on other signed apps.

fenfenxu · 1 month ago

<img width="1024" height="542" alt="Image" src="https://github.com/user-attachments/assets/9f00e573-7a6a-4152-ad1d-914e66f66783" />

Gemini suggested that I execute this command to debug the issue:

sudo fs_usage -w -f filesys | grep -i "failed"

Here is the log output I captured:

sudo fs_usage -w -f filesys | grep -i "failed"

here is the output:

0.000001   xattr.90036212

09:39:28.509281  open              F=18       (R_____________)  /Applications/Codex.app/Contents/Info.plist                                                                                                                   0.000019   syspolicyd.86478192

09:39:28.509282  fstat64           F=18                                                                                                                                                                                       0.000001   syspolicyd.86478192

09:39:28.509285  lstat64                                ons/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreGraphics.framework/Versions/A/Headers/CGLayer.h    0.000039   xattr.90036199

09:39:28.509285  open              F=4        (R_____________)  /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/SDKSettings.plist                                                                                     0.000012   git.90036150

09:39:28.509285  fstat64           F=4                                                                                                                                                                                        0.000001   git.90036150

09:39:28.509286  lstat64                                /Applications/Codex.app/Contents/Info.plist                                                                                                                           0.000004   syspolicyd.86478192

09:39:28.509287  fstat64           F=18                                                                                                                                                                                       0.000001   syspolicyd.86478192

09:39:28.509288  read              F=4    B=0x1307                                                                                                                                                                            0.000003   git.90036150

09:39:28.509289  close             F=4                                                                                                                                                                                        0.000001   git.90036150

09:39:28.509290  read              F=18   B=0x49ec                                                                                                                                                                            0.000003   syspolicyd.86478192

09:39:28.509291  close             F=18                                                                                                                                                                                       0.000001   syspolicyd.86478192

09:39:28.509328  open              F=3        (R_____________)  e.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreGraphics.framework/Versions/A/Headers/CGLayer.h    0.000043   xattr.90036199

09:39:28.509329  fstat64           F=3                                                                                                                                                                                        0.000001   xattr.90036199

09:39:28.509336  flistxattr        F=3                                                                                                                                                                                        0.000006   xattr.90036199

09:39:28.509341  flistxattr        F=3                                                                                                                                                                                        0.000002   xattr.90036199

09:39:28.509342  open              F=4        (R_____________)  /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/SDKSettings.plist                                                                                     0.000011   git.90036150

--

09:39:28.509448  fcntl             F=19  <OFD_SETLK>                                                                                                                                                                          0.000001   trustd.89821276

09:39:28.509463  open              F=4        (R_____________)  /Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk/SDKSettings.plist                                                                                     0.000011   git.90036150

09:39:28.509464  fstat64           F=4                                                                                                                                                                                        0.000001   git.90036150

09:39:28.509466  read              F=4    B=0x1315 

Gemini analyzed these logs and indicated that there were two high-frequency operation conflicts triggering macOS security mechanisms:

  1. Excessive scanning of the Codex app: syspolicyd was repeatedly performing open, fstat64, and read operations on /Applications/Codex.app/Contents/Info.plist, likely due to signature verification issues.
  2. SDK path conflicts: The git process was frequently reading SDKSettings.plist files, which may be caused by outdated or missing SDK configurations in my project.

I decided to verify this by checking for updates in the Codex app. A dialog appeared asking me to update or update & restart. After I clicked the "Update & Restart" button, the CPU usage dropped immediately.

<img width="1024" height="542" alt="Image" src="https://github.com/user-attachments/assets/664da212-c170-402e-9e73-beae475793ae" />

fenfenxu · 1 month ago

now this my codex app version:

Version 26.609.71144 • Released Jun 16, 2026

Alex009 · 1 month ago

same issue on 26.609.71450.
syspolicyd eat CPU. also after small time (10-20 min) new processes can't start (just can't open terminal for example). only reboot helps. if i run codex after reboot - all will broke again. so now i can't use codex at all.
macos 26.4 (25E246)
M1 Max

theadhdguy · 1 month ago

I am facing the Same issue, codex Version 26.609.71450
OS : 26.5.1 (25F80)

GardnerLou · 1 month ago

Same issue for here. Started happening June 11th for me. Stopped using until today to see if there was an update via OAI.

Today tried to update today and failed then cleared system cache and updated to 26.611.62324 (successfully) but met with same results as June 11:

Codex 26.611.62324 / bundle 4028 on macOS
codesign intermittently fails with invalid signature spctl reports "Too many open files" or "bundle format unrecognized" Launching Codex drives Codex >100% CPU, syspolicyd ~60%, trustd ~45%

Fans run hot, system super slow.
Unusable.

jamguoxiaoqi · 27 days ago

I encountered this syspolicyd problem yesterday on a very fresh version:
Version 26.616.71553 • Released Jun 23, 2026

I tried many ways I can find in all comments from all issues I can found but no one works.
Until I found a stray/corrupted .git folder under one of my codex working directory, which contains multiple repos (but it should not have its own .git).

$ find .
.
./objects
./objects/pack
./objects/pack/tmp_idx_10pAga
./objects/pack/tmp_idx_TqD4PQ

I removed it and everything is fine now.

After open Codex App, syspolicyd will run at ~50% for only couple seconds, not infinitively 150% anymore.
computer use, browsers, etc. are all enabled.

Hope this helps.

murbanowicz · 26 days ago

Same here!

hgupt3 · 25 days ago

Adding a related reproduction on a newer Codex Desktop build. This is similar to the .git/workspace-trigger data point above, but in this case the trigger was a broken .git file containing an absolute gitdir: pointer synced from another Mac.

Environment

macOS: 26.2 (25C56)
Architecture: arm64
Hardware: Apple Silicon / M2 Pro
Codex Desktop: 26.623.30605 (CFBundleVersion 4415)
Bundled CLI: codex-cli 0.142.2
Workspace location: iCloud Drive-backed folder

Trigger

The workspace had a .git file that contained an absolute gitdir pointer from another machine:

gitdir: /Users/<user>/Agent Workbench/Backups/git/agent-hub.git

On this Mac, that target path did not exist. Any Git operation in the workspace failed immediately:

fatal: not a git repository: /Users/<user>/Agent Workbench/Backups/git/agent-hub.git

This appears to happen naturally if a workspace is synced via iCloud Drive but its --separate-git-dir target is local to another Mac.

Observed behavior

With Codex Desktop open on that workspace, the Mac entered the same SystemPolicy failure class described in this issue:

  • syspolicyd and trustd climbed to roughly ~50% CPU each.
  • unrelated apps were affected; Chrome would show as launched/bouncing but not create a usable window.
  • already-loaded browser pages were usable, but new app/browser launches became unreliable.
  • real network checks (curl, ping, DNS) were fast, so this was not a network issue.

Unified log count while bad:

log show --last 30s --predicate 'process == "syspolicyd" OR process == "trustd"' | grep -c 'violates validation category policy'
# ~1492 in 30 seconds

Representative log pattern:

syspolicyd ... <private> with PID <rapidly increasing> violates validation category policy. This will likely result in a block in the future
trustd ... SecKeyVerifySignature

A privileged short fs_usage -w -f exec sample showed Codex repeatedly spawning Git/CLT-related processes from the workspace, including repeated executions of:

/Library/Developer/CommandLineTools/usr/bin/git
/usr/bin/xcode-select

Mitigation that stopped the storm

  1. Move the broken .git pointer aside.
  2. Create the missing local gitdir path on this machine.
  3. Reattach the workspace with git init --separate-git-dir=....

After that:

git status --short
# completed in ~0.01s instead of failing

And the SystemPolicy storm dropped sharply:

validation-policy hits: ~1492 / 30s before
validation-policy hits: ~14 / 30s immediately after moving the broken pointer aside
validation-policy hits: 0-1 / 30s after reattaching a valid local gitdir and letting the system settle

Chrome then launched normally again and loaded normal sites quickly.

Why this seems useful

This suggests one trigger path is not only Computer Use / code-sign clone / app attestation. A bad Git workspace state can also amplify the issue if Codex Desktop repeatedly probes Git without enough backoff.

In this repro, the root local condition was specifically:

.git file -> absolute gitdir path -> target missing on this Mac

Suggested Codex-side mitigation:

  • Detect an invalid .git gitdir: target once and mark Git unavailable/degraded for that workspace.
  • Back off instead of repeatedly spawning Git and related CLT tools.
  • Surface a workspace diagnostic like “Git metadata points to a missing local path.”
  • Avoid high-frequency short-lived git/xcode-select process launch loops from the app/sidebar/review-summary path.

Separate note: I also saw lower-rate trustd warnings mentioning 2DC432GLL2.com.openai.sky.CUAService, but the high-rate violates validation category policy storm correlated with the broken Git pointer and stopped after the Git metadata was repaired.

jamguoxiaoqi · 25 days ago

I made 5 different .git and then test them out by copying .git to a workspace root directory.

mkdir -p a-broken-pack/.git/objects/pack
touch a-broken-pack/.git/objects/pack/tmp_idx_10pAga

mkdir -p b-empty-dotgit/.git

mkdir -p c-head-only/.git
printf 'ref: refs/heads/main\n' > c-head-only/.git/HEAD

mkdir -p d-broken-gitfile
printf 'gitdir: /tmp/does-not-exist-anywhere\n' > d-broken-gitfile/.git

mkdir -p e-unborn
git init e-unborn

A,B,C,D will trigger the problem. E won't.

D is the same scenario as @hgupt3 tried.