claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Files named 'nul' created on Windows instead of using NUL device

Open Rsrsys opened this issue 10 months ago • 1 comments

Description

Claude Code is creating actual files named nul in various directories on Windows. This appears to be a bug where code intended to write to the Windows NUL device (equivalent to /dev/null) instead creates a real file.

Evidence

Found 9 files named nul scattered across project directories after a couple days of irregular usage:

./ProjectA/nul
./ProjectB/SubfolderApi/nul
./ProjectB/nul
./ProjectB/WebApp/nul
./ProjectC/AdminWeb/nul
./ProjectD/nul
./ProjectE/ERP/nul
./nul

Probable cause

When running in a bash environment on Windows (Git Bash, WSL, etc.), writing to NUL or nul creates an actual file instead of discarding output as intended. The code should use /dev/null when in a bash context, or properly detect the environment.

Expected behavior

Output intended to be discarded should not create files.

Environment

  • Platform: Windows 11
  • Claude Code CLI (running in bash environment)

Workaround

Manual cleanup with: find . -name "nul" -type f -delete

Rsrsys avatar Jan 13 '26 08:01 Rsrsys

it happened to me, so, +1

sirventai avatar Jan 13 '26 10:01 sirventai

Happens all the time for long time :) Have to open VS Code to delete those.

ruzrobert avatar Jan 21 '26 10:01 ruzrobert

+1, please fix this extremely annoying behaviour!

liama86 avatar Jan 23 '26 11:01 liama86

+1

HeyyCzer avatar Feb 02 '26 02:02 HeyyCzer

Image

+1

andaoai avatar Feb 03 '26 07:02 andaoai

I've added this to my claude.md

## bash commands
don't pipe to /dev/nul. we run git bash on windows and it doesn't work.

ssippe avatar Feb 04 '26 00:02 ssippe

I have the same issue and I am not able to delete those files

shifoc avatar Feb 07 '26 14:02 shifoc

FWIW, some tips for deleting this file were shared in other threads: https://github.com/anthropics/claude-code/issues/4928

jcouv avatar Feb 07 '26 20:02 jcouv

Consolidating issues

ant-kurt avatar Feb 13 '26 23:02 ant-kurt

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Feb 21 '26 14:02 github-actions[bot]