[BUG] Deploy initial-commit step reads .git/info/exclude with the locale encoding and crashes on Windows for UTF-8 patterns
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start in lib/cli/src/crewai_cli/git.py at Repository._ensure_initial_commit_excludes, used by Repository.initialize and create_initial_commit_if_needed. Reproduce the Windows failure with the issue's UTF-8 exclude pattern, then add regression coverage for preserving UTF-8 content and existing line endings. Done means deploy initialization handles the file without decoding errors or changing its existing patterns and line endings.
Written by the indexing model from the issue text.
Description
Description
Repository._ensure_initial_commit_excludes in lib/cli/src/crewai_cli/git.py (used by Repository.initialize / create_initial_commit_if_needed, the crewai deploy path that auto-creates an initial commit) reads and rewrites .git/info/exclude with Path.read_text() / Path.write_text() and no encoding. Git stores ignore patterns as raw UTF-8 bytes regardless of platform, but on Windows Python decodes them as cp1252. Any pattern containing a code point whose UTF-8 encoding includes 0x81/0x8D/0x8F/0x90/0x9D (curly quotes, many CJK characters, Đ, Ł, Ё) raises UnicodeDecodeError and aborts the deploy. On non-UTF-8 CJK code pages (cp932, cp936) ordinary filenames hit this. The rewrite also converts the file's line endings to CRLF on Windows.
Steps to Reproduce
On Windows with the default cp1252 locale:
import os, subprocess, tempfile
from crewai_cli.git import Repository
d = tempfile.mkdtemp()
subprocess.run(["git", "init", "-q", d], check=True)
excl = os.path.join(d, ".git", "info", "exclude")
with open(excl, "ab") as f:
f.write("notes \u201cdraft\u201d.md\n".encode("utf-8")) # curly quotes -> bytes E2 80 9C / E2 80 9D
Repository(path=d, fetch=False)._ensure_initial_commit_excludes()
Expected behavior
Existing patterns are preserved byte-for-byte and the CrewAI block is appended, on every platform, with the file's line endings left alone.
Screenshots/Code snippets
File "...\lib\cli\src\crewai_cli\git.py", line 166, in _ensure_initial_commit_excludes
existing = exclude_file.read_text() if exclude_file.exists() else ""
File "...\Lib\encodings\cp1252.py", line 23, in decode
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 6: character maps to <undefined>
Operating System
Windows 11
Python Version
3.13
crewAI Version
main @ bbcebffbf (1.15.22+)
crewai-tools Version
same workspace commit
Proposed fix
Read and write the file as UTF-8 (encoding="utf-8"), and write with newline="\n" so the rewrite does not change line endings. PR with a regression test follows.
Disclosure per CONTRIBUTING: this report and the fix were prepared with the help of an AI coding assistant; please apply the llm-generated label.
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crewAIInc/crewAI
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
[BUG] AttributeError: 'int' object has no attribute 'get' in crew_run_tui.py during plan rendering Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
All issues in crewAIInc/crewAI
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100