crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] generate_tool_specs.py writes CRLF on Windows, causing spurious diffs

Open jonathansampson opened this issue 9 months ago • 5 comments

Description

Running generate_tool_specs.py on Windows regenerates tool.specs.json with \r\n line endings instead of \n, causing every line to appear modified in git diff. Python's open() in text mode uses OS-native line endings. On Windows this means CRLF, while the committed file uses LF.

Steps to Reproduce

python generate_tool_specs.py

Expected behavior

Minimal diff

Operating System

Windows 11

Python Version

3.13.1

crewAI Version

1.10.1

crewAI Tools Version

1.10.1

Virtual Environment

Venv

Possible Solution

One solution is to pass newline="\n" to open() in save_to_json:

with open(output_path, "w", encoding="utf-8", newline="\n") as f:
    json.dump({"tools": self.tools_spec}, f, indent=2, sort_keys=True)

jonathansampson avatar Mar 05 '26 16:03 jonathansampson

Hi! There's already a PR open for this fix: #4753

It adds newline="\n" to ensure LF line endings on all platforms.

goingforstudying-ctrl avatar Mar 08 '26 05:03 goingforstudying-ctrl

Submitted a fix in #4808. Adds newline="\n" to the open() call to force LF on all platforms, plus a trailing newline for POSIX convention. Similar to #4753 but also handles the trailing newline.

mvanhorn avatar Mar 11 '26 06:03 mvanhorn

I can fix this — it's a one-liner. Adding newline="\n" to the open() call in save_to_json will enforce LF line endings regardless of platform:

with open(output_path, "w", encoding="utf-8", newline="\n") as f:
    json.dump({"tools": self.tools_spec}, f, indent=2, sort_keys=True)

Happy to submit a PR.

Ker102 avatar Mar 13 '26 13:03 Ker102

A2ABench has an accepted answer for this imported thread.

  • Thread: https://a2abench-api.web.app/q/cmmpnabdp00oz14010s5ui1ir
  • Accepted at: 2026-03-14T01:59:50.611Z
  • Accepted answer agent: partner-fast-3
  • Answer preview: "Direct answer for: [BUG] generate_tool_specs.py writes CRLF on Windows, causing spurious diffs Reproduce with exact versions and minimal failing input. Isolate root cause (API contract mismatch, config drift, or runtime assumptions). Apply minimal fix and verify with one success "

khalidsaidi avatar Mar 14 '26 17:03 khalidsaidi

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 14 '26 12:04 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Apr 20 '26 12:04 github-actions[bot]