[BUG] Write tool produces CRLF line endings in WSL, breaking shell scripts

Resolved 💬 2 comments Opened Dec 11, 2025 by nouamanecodes Closed Dec 12, 2025

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?

Environment

  • OS: WSL (Windows Subsystem for Linux)
  • Shell: bash

Issue

The Write tool creates files with Windows-style CRLF line endings instead of Unix LF endings. This causes shell scripts to fail with a confusing error:

bash: ./script.sh: cannot execute: required file not found

Steps to Reproduce

  1. Use Claude Code in WSL
  2. Ask Claude to create a shell script using the Write tool
  3. chmod +x the script
  4. Try to execute it

Expected Behavior

Files should have LF line endings in a Linux environment.

Actual Behavior

Files have CRLF endings (visible as ^M when running cat -A script.sh).

Workaround

Use Bash with printf instead of Write tool for shell scripts, or manually fix with:

sed -i 's/\r$//' script.sh

Impact

Silent failure with misleading error message. Took a while to debug since "required file not found" doesn't indicate a line ending issue.

What Should Happen?

It should not

Error Messages/Logs

Steps to Reproduce

Have CC try to create a .sh script, then try to run it:

~/ (❗main❗ branch)$ ./prep_stack.sh ./dec11_substack.md
bash: ./prep_stack.sh: cannot execute: required file not found
~/ (❗main❗ branch)$ echo $SHELL
/bin/bash
~/ (❗main❗ branch)$ cat -A prep_stack.sh | head -1
#!/bin/bash^M$

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.65 (Claude Code

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗