Skip to content

The mysterious NUL file problem ​

AI tools sometimes create nul files that you can’t delete normally. Here’s how to fix it.

The problem ​

Some AI tools (Cursor, Copilot, and similar) accidentally create files named nul, which is a reserved name in Windows. That makes them impossible to delete with File Explorer or a normal del.

You’ll see errors — and the file stays put.

Git won’t push it ​

Git treats nul as reserved and effectively ignores it, so your remote is usually safe. It can still clutter the working tree and confuse git status.

The solution ​

Run PowerShell as Administrator and delete via the Windows UNC path:

powershell
cmd /c del /f /q "\\?\C:\YOUR-FOLDER\nul"

Step by step ​

  1. Open PowerShell as Administrator (right-click Start → Terminal/PowerShell (Admin))
  2. Replace YOUR-FOLDER with the real path
  3. Run the command

Example ​

powershell
# If your project is in C:\Users\you\projects\my-app
cmd /c del /f /q "\\?\C:\Users\you\projects\my-app\nul"

Why this works ​

The \\?\ prefix tells Windows to bypass normal path parsing and access the file directly. That lets you target reserved names that normal APIs block.

Other reserved names ​

Same class of problem:

CON · PRN · AUX · NUL · COM0–COM9 · LPT0–LPT9

Further reading ​