Skip to content

EXE002 on file systems that do not support executable bit #12941

@Argmaster

Description

@Argmaster

This issue is somewhat releated to #5445 and #10084 but applies to more generic version of reported issues.
In general on NTFS and on FAT file systems executable permissions are not avialable by default resulting in all files being executable. What I noticed is that the problem is not as simple as avoiding checking this rule on windows / wsl etc. as NTFS and FAT system may also be used for drives which are shared between Windows and Linux OS.

In my case, I have an exFAT drive shared between Windows 11 and Ubuntu 24.04 and all files appear as executable. When I am running ruff on Ubuntu 24.04 EXE002 is triggered.

-rwxr-xr-x  1 argmaster argmaster   2543 Aug 16 19:53 conftest.py
drwxr-xr-x  3 argmaster argmaster 131072 Aug 16 20:29 examples
drwxr-xr-x 11 argmaster argmaster 131072 Aug 16 19:56 gerberx3
-rwxr-xr-x  1 argmaster argmaster     35 Aug 16 19:53 .gitignore

Hence I would recommend adding some additional heuristic to detect if filesystem used supports executable permissions. This should only be needed on Unix family of operating systems.

Simple, although not perfect way to detect if file system supports executable bit could be to create temporary file next to a python file we are checking and make an attempt to toggle executable bit on it. Handling symlinks could get tricky though. I am not knowledgable enough to suggest better solution unfortunately.

Python 3.12.0
ruff 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions