Skip to content

fix(build): keep shell scripts LF so Windows checkouts do not break bash - #3010

Closed
windalser wants to merge 1 commit into
block:mainfrom
windalser:fix/gitattributes-lf-shell-scripts
Closed

fix(build): keep shell scripts LF so Windows checkouts do not break bash#3010
windalser wants to merge 1 commit into
block:mainfrom
windalser:fix/gitattributes-lf-shell-scripts

Conversation

@windalser

Copy link
Copy Markdown

Summary

The repo has no .gitattributes. With core.autocrlf=true — the Git for Windows
default — every checkout rewrites *.sh with CRLF, and running them under Git Bash
then fails with $'\r': command not found. This breaks the scripts that just
recipes and the dev setup depend on (scripts/instance-env.sh,
scripts/seed-local-community.sh, deploy/compose/run.sh, and the rest), and it
recurs after every checkout / pull, so a local fix does not hold.

Adds a single rule pinning *.sh to LF.

Deliberately not * text=auto: that would renormalize the entire working tree
(~2800 files here) and invalidate every cargo and vite build cache for anyone who
already has CRLF checked out. Scoping to *.sh fixes the files that actually break
and is a no-op on macOS and Linux.

Related issue

None found — searched open and closed issues and PRs for gitattributes, CRLF,
and line endings.

Testing

On Windows 11 with core.autocrlf=true, before the change:

$ rm scripts/instance-env.sh && git checkout -- scripts/instance-env.sh
$ grep -cU $'\r' scripts/instance-env.sh
71                      # CRLF -> bash fails

After the change, same steps across every tracked *.sh:

$ for f in $(git ls-files '*.sh'); do grep -qU $'\r' "$f" && echo "CRLF: $f"; done
                        # no output — all LF

git status stays clean; no other file is touched.

🤖 Generated with Claude Code

With core.autocrlf=true (the Git for Windows default) every checkout rewrote
*.sh with CRLF, so running them under Git Bash failed with
`$'\r': command not found`. The repo had no .gitattributes at all.

Scoped to *.sh deliberately: a `* text=auto` rule would renormalize the whole
tree and invalidate every cargo/vite build cache.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@windalser
windalser requested a review from a team as a code owner July 26, 2026 18:00
@wpfleger96

Copy link
Copy Markdown
Member

🤖 hey @windalser — thank you for this contribution. The diagnosis is right: with core.autocrlf=true (the Git for Windows default) a checkout rewrites *.sh to CRLF and bash dies with $'\r': command not found.

Closing this as superseded by #2943, which is landing a repo-wide .gitattributes (* text=auto eol=lf) that covers *.sh plus the extensionless bash scripts under bin/ that a *.sh glob misses. On the build-cache concern in your commit message: we checked every blob on main — the tree is already all-LF, so the global rule renormalizes nothing today; it only pins future checkouts, exactly like your version.

@wpfleger96 wpfleger96 closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants