claude-code - 💡(How to fix) Fix sed on Windows silently converts CRLF to LF, breaking files [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

When Claude Code runs on Windows (bash shell via Git Bash), using sed -i to edit files silently converts CRLF line endings to LF. This happens without any warning or error, and the resulting files appear identical in content but are broken for Windows tools that expect CRLF. 2. Warn when sed will change line endings The platform instructions (windows-environment.md) already warn about this, but the model does not consistently follow them. The Edit tool preserves line endings correctly -- sed via Bash does not.

Root Cause

In my case, this caused ~4 hours of debugging a ScriptInstaller XML manifest that stopped working after Claude edited it with sed. The content looked correct in every inspection, but the .NET XML parser failed silently because the line endings were LF instead of CRLF. Multiple rounds of structural changes and re-packaging were attempted before the root cause was identified.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Bug

When Claude Code runs on Windows (bash shell via Git Bash), using sed -i to edit files silently converts CRLF line endings to LF. This happens without any warning or error, and the resulting files appear identical in content but are broken for Windows tools that expect CRLF.

Impact

In my case, this caused ~4 hours of debugging a ScriptInstaller XML manifest that stopped working after Claude edited it with sed. The content looked correct in every inspection, but the .NET XML parser failed silently because the line endings were LF instead of CRLF. Multiple rounds of structural changes and re-packaging were attempted before the root cause was identified.

Reproduction

  1. On Windows with Claude Code (bash shell)
  2. Have a file with CRLF line endings (standard Windows)
  3. Ask Claude to edit the file using sed (e.g., remove a pattern)
  4. file command confirms the output is now LF-only

Expected behavior

Claude Code on Windows should either:

  1. Not use sed for file edits on Windows (prefer PowerShell or the Edit tool)
  2. Warn when sed will change line endings
  3. Automatically preserve line endings after sed operations

Environment

  • Platform: Windows 11 Pro
  • Shell: bash (Git Bash)
  • Claude Code CLI

Notes

The platform instructions (windows-environment.md) already warn about this, but the model does not consistently follow them. The Edit tool preserves line endings correctly -- sed via Bash does not.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Claude Code on Windows should either:

  1. Not use sed for file edits on Windows (prefer PowerShell or the Edit tool)
  2. Warn when sed will change line endings
  3. Automatically preserve line endings after sed operations

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix sed on Windows silently converts CRLF to LF, breaking files [1 pull requests]