Write tool produces CRLF line endings on WSL2 (Linux) instead of LF

Resolved 💬 3 comments Opened Mar 3, 2026 by miyunart89 Closed Apr 1, 2026

Bug

The Write tool produces files with \r\n (CRLF) line endings on WSL2, even though the platform is Linux where \n (LF) is expected. The Edit tool correctly preserves existing line endings.

Environment

  • Claude Code: 2.1.50
  • OS: Ubuntu 24.04.4 LTS on WSL2
  • Kernel: 6.6.87.2-microsoft-standard-WSL2
  • Node: v24.13.1
  • Filesystem: ext4 (native Linux, not Windows mount)
  • process.platform: linux
  • os.EOL: \n

Reproduction

Write tool creates CRLF:

# Ask Claude to write a file using the Write tool
Write file: /tmp/test.md with content "line1\nline2\n"

$ od -c /tmp/test.md
0000000   l   i   n   e   1  \r  \n   l   i   n   e   2  \r  \n

Edit tool preserves LF correctly:

# Create a LF file, then ask Claude to edit it
$ printf "line1\nline2\n" > /tmp/test.txt

# Edit tool replaces "line1" with "changed"
$ od -c /tmp/test.txt
0000000   c   h   a   n   g   e   d  \n   l   i   n   e   2  \n
# LF preserved ✓

Bash tool produces LF correctly:

$ echo "test" > /tmp/test.txt && od -c /tmp/test.txt
0000000   t   e   s   t  \n

Impact

  • Tools that parse file content (YAML frontmatter, config files) can break when they expect LF
  • Repositories accumulate mixed line endings (LF from Edit, CRLF from Write)
  • git diff shows spurious changes when files are later normalized

Expected behavior

The Write tool should produce LF line endings on Linux/WSL2, consistent with os.EOL and process.platform.

Notes

  • Same Ubuntu version on native Linux produces LF correctly
  • Only the Write tool is affected; Edit and Bash tools work as expected
  • The project filesystem is ext4, not a Windows NTFS mount (/mnt/c/)

View original on GitHub ↗

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