Bash tool creates NUL files on Windows, breaking OneDrive sync
Bug Report: Bash tool creates NUL files on Windows, breaking OneDrive sync
Summary
When Claude Code runs Bash commands on Windows (using Git Bash), commands that redirect output to NUL create an actual file named "NUL" instead of redirecting to the Windows null device. This breaks OneDrive sync because "NUL" is a reserved Windows filename that OneDrive cannot process.
Environment
- OS: Windows 11
- Claude Code Version: Latest (as of 2025-12-30)
- Shell: Git Bash (bundled with Git for Windows)
Steps to Reproduce
- Use Claude Code on Windows with OneDrive folder as working directory
- Run any command that includes output redirection to NUL, e.g.:
some_command 2>NULping -n 1 127.0.0.1 > nul
- Observe that a file named "NUL" is created in the current directory
- OneDrive will report sync errors because "NUL" is a reserved Windows filename
Expected Behavior
Output redirected to NUL should go to the null device (be discarded), not create a file.
Actual Behavior
A file named "NUL" is created in the working directory. This file:
- Cannot be synced by OneDrive (reserved name)
- Cannot be easily deleted through normal Windows file operations
- Requires special handling via
\\?\path prefix to delete
Root Cause
Git Bash on Windows doesn't recognize NUL as the Windows null device. It interprets > NUL as "redirect to a file named NUL".
The correct way to redirect to null in Git Bash is /dev/null, not NUL.
Suggested Fix
When Claude Code's Bash tool runs on Windows with Git Bash:
- Replace
> NUL,2> NUL,2>NULetc. with> /dev/null,2> /dev/nullin commands - Or use Git Bash's
/dev/nullconsistently instead of Windows-styleNUL
Workaround
I've implemented a file system watcher that monitors for NUL file creation and deletes them immediately. This works but adds unnecessary overhead.
Impact
- High for users with OneDrive/cloud sync: Sync completely stops until NUL files are manually deleted
- Medium for other users: Spurious files created in working directories
Additional Context
This happens frequently during normal Claude Code usage, especially when commands involve error suppression or quiet modes that redirect to null.
---
To submit: Go to https://github.com/anthropics/claude-code/issues and create a new issue with this content.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗