Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff format --check Fails on Ubuntu #15391

Open
MelbourneDeveloper opened this issue Jan 9, 2025 · 3 comments
Open

ruff format --check Fails on Ubuntu #15391

MelbourneDeveloper opened this issue Jan 9, 2025 · 3 comments
Labels
formatter Related to the formatter needs-mre Needs more information for reproduction

Comments

@MelbourneDeveloper
Copy link

I am working on macOS, and I use GitHub Actions. I run this in the pipeline:

ruff format --check .

It passes on Mac, but fails in Ubuntu. This is what I get:

ruff format --check .
Would reformat: ai_coding_agent/tests/test_api_e2e.py
Would reformat: ai_coding_agent/tests/test_devagent.py
Would reformat: ai_coding_agent/tests/test_devagent_e2e.py
3 files would be reformatted, 34 files already formatted

Three files in particular are not formatted the same way. The rest are fine,. I would guess that this a line ending issue, but I've tried changing git attributes etc. and nothing seemed to make any difference. I've tried hard refreshing these files and also I tried running this on Ubuntu before running the formatting check:

find . -name "*.py" -type f -exec perl -pi -e 's/\r\n|\r/\n/g' {} +

Nothing seems to make any difference.

I couldn't see any specific config for line endings in the documentation here.

@zanieb
Copy link
Member

zanieb commented Jan 9, 2025

Can you share a reproducible example? i.e. host the file somewhere?

@MichaReiser MichaReiser added the needs-mre Needs more information for reproduction label Jan 10, 2025
@MichaReiser MichaReiser transferred this issue from astral-sh/ruff-vscode Jan 10, 2025
@MichaReiser MichaReiser added the formatter Related to the formatter label Jan 10, 2025
ss77995ss added a commit to ss77995ss/baseball-stats-python that referenced this issue Jan 12, 2025
ss77995ss added a commit to ss77995ss/baseball-stats-python that referenced this issue Jan 12, 2025
@MelbourneDeveloper
Copy link
Author

@zanieb unfortunately, I can't. However, I have been able to reproduce the problem locally on my Mac, and it's totally bizarre.

When I run this script:

#!/bin/bash

set -e

source venv/bin/activate

ruff format --check .

I get this:

Would reformat: ai_coding_agent/tests/test_api_e2e.py
Would reformat: ai_coding_agent/tests/test_devagent.py
Would reformat: ai_coding_agent/tests/test_devagent_e2e.py
Would reformat: ai_coding_agent/tests/test_devagent_mocks.py
Would reformat: ai_coding_agent/tests/test_devagent_unit.py
5 files would be reformatted, 34 files already formatted

If I remove or delete the activation beforehand, the format check passes

#!/bin/bash

set -e

ruff format --check .

39 files already formatted

@zanieb
Copy link
Member

zanieb commented Jan 17, 2025

When you activate the environment are you getting a different version of Ruff? e.g., which ruff / ruff version in both examples? Are you using the same Python version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter needs-mre Needs more information for reproduction
Projects
None yet
Development

No branches or pull requests

3 participants