[BUG] EINVAL: invalid argument on Windows - Task output file path mangling in v2.1.53
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code fails to execute any task with an EINVAL: invalid argument error when opening a task output file. The temporary file path is being incorrectly generated — the project working directory path is being mangled during path sanitization.
For example, a working directory like C:\Users\<username>\desktop\my-project gets converted to C--Use rs-<username>-desktop-my-project (with a space inserted after "Use"), creating an invalid path that Windows cannot open.
The path sanitization logic appears to be truncating or splitting path components around the Users directory name, introducing a space that breaks the file open operation.
What Should Happen?
Claude Code should correctly sanitize the working directory path for use in temporary file paths without introducing spaces or truncating path components. The expected sanitized directory name should be continuous without spaces, e.g. C--Users-<username>-desktop-my-project.
Error Messages/Logs
Error: EINVAL: invalid argument, open 'C:\Users\<username>\AppData\Local\Temp\claude\C--Use rs-<username>-desktop-my-project\tasks\<task-id>.output'
Steps to Reproduce
- Install Claude Code v2.1.53 natively on Windows
- Navigate to a project directory under C:\Users\<username>\desktop\
- Run
claudeand attempt any task - Observe the EINVAL error when Claude tries to open the task output file
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.52
Claude Code Version
2.1.53
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
- This started happening after an automatic update to v2.1.53. The previous version worked without any issues.
- The bug appears to be in the path sanitization logic that converts the CWD into a temp directory name. The string "Users" is being split into "Use" + "rs" with a space in between.
- Clearing the temp directory (
%LOCALAPPDATA%\Temp\claude) does not resolve the issue. - The project path contains no special characters or spaces — only standard alphanumeric characters, hyphens, and backslashes.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗