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

ERROR: I am having ruff check issue when runnning tox in WSL #2649

Open
h4l0gen opened this issue May 29, 2024 · 9 comments
Open

ERROR: I am having ruff check issue when runnning tox in WSL #2649

h4l0gen opened this issue May 29, 2024 · 9 comments

Comments

@h4l0gen
Copy link
Contributor

h4l0gen commented May 29, 2024

Description of issue or feature request:
I am having ruff check issue when runnning tox in WSL. It shows Linting error of shebang in executable file, see
$ tox -e fix

fix: install_deps> python3 -m pip install -e . -r /mnt/c/Users/ks391/OneDrive/Desktop/open_source/TUF_WEBSITE/simple_envelope/python-tuf/requirements/lint.txt
fix: commands[0]> ruff check --fix tuf examples tests verify_release
examples/manual_repo/basic_repo.py:1:1: EXE002 The file is executable but no shebang is present 

This issue is specific to WSL only, working fine in Linux/Ubuntu.

I know this is not required to put shebang in executable files, But if we can fix or document it?

@h4l0gen h4l0gen changed the title ERROR: I am having ruff check issue in when runnning tox in WSL ERROR: I am having ruff check issue when runnning tox in WSL May 29, 2024
@jku
Copy link
Member

jku commented May 29, 2024

examples/manual_repo/basic_repo.py:1:1: EXE002 The file is executable but no shebang is present

that is a little strange -- the file is not executable in git (you could argue it could as well be but currently it isn't).

@h4l0gen
Copy link
Contributor Author

h4l0gen commented May 29, 2024

Yes, am reading official ruff page, found that my python version is 3.10, but after upgrading it to 3.11, as per ruff, it still shows error.
@jku this shows shebang error to these many files (i.e. executable)

lint: recreate env because python changed version_info=[3, 10, 12, 'final', 0]->[3, 11, 0, 'candidate', 1] | executable='/usr/bin/python3.10'->'/usr/bin/python3.11'
lint: remove tox env folder /mnt/c/Users/ks391/OneDrive/Desktop/open_source/TUF_WEBSITE/simple_envelope/python-tuf/.tox/lint
lint: install_deps> python3 -m pip install -e . -r /mnt/c/Users/ks391/OneDrive/Desktop/open_source/TUF_WEBSITE/simple_envelope/python-tuf/requirements/lint.txt
lint: commands[0]> ruff check tuf examples tests verify_release
examples/manual_repo/basic_repo.py:1:1: EXE002 The file is executable but no shebang is present
examples/manual_repo/hashed_bin_delegation.py:1:1: EXE002 The file is executable but no shebang is present
examples/manual_repo/succinct_hash_bin_delegations.py:1:1: EXE002 The file is executable but no shebang is present
examples/repository/_simplerepo.py:1:1: EXE002 The file is executable but no shebang is present
examples/uploader/_localrepo.py:1:1: EXE002 The file is executable but no shebang is present
tests/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tests/generated_data/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tests/generated_data/generate_md.py:1:1: EXE002 The file is executable but no shebang is present
tests/repository_simulator.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_api.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_examples.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_fetcher_ng.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_metadata_eq_.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_metadata_generation.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_metadata_serialization.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_trusted_metadata_set.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_consistent_snapshot.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_delegation_graphs.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_fetch_target.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_key_rotations.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_ng.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_top_level_update.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_updater_validation.py:1:1: EXE002 The file is executable but no shebang is present
tests/test_utils.py:1:1: EXE002 The file is executable but no shebang is present
tests/utils.py:1:1: EXE002 The file is executable but no shebang is present
tuf/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/_payload.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/dsse.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/exceptions.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/metadata.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/serialization/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/api/serialization/json.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/_internal/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/_internal/requests_fetcher.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/_internal/trusted_metadata_set.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/config.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/fetcher.py:1:1: EXE002 The file is executable but no shebang is present
tuf/ngclient/updater.py:1:1: EXE002 The file is executable but no shebang is present
tuf/repository/__init__.py:1:1: EXE002 The file is executable but no shebang is present
tuf/repository/_repository.py:1:1: EXE002 The file is executable but no shebang is present
Found 42 errors.
lint: exit 1 (0.49 seconds) /mnt/c/Users/ks391/OneDrive/Desktop/open_source/TUF_WEBSITE/simple_envelope/python-tuf> ruff check tuf examples tests verify_release pid=14022
lint: FAIL ✖ in 3 minutes 55.46 seconds

@jku
Copy link
Member

jku commented May 29, 2024

Oh yeah, if it's every file then this is a Windows thing: their filesystem does not have executable flag -- so in WSL every file (on a windows filesystem) is marked executable.

That said, this should be worked around in ruff already...
astral-sh/ruff#5445

@h4l0gen
Copy link
Contributor Author

h4l0gen commented May 29, 2024

Oh great, then IMO we should document it here with possible solution (I will check if i can found something) So that we don't need to worry about it anymore. WYT? @jku

@jku
Copy link
Member

jku commented May 29, 2024

I think we don't quite understand why you are seeing the issue:

  • based on the linked ruff issue, ruff should be skipping EXE001 and EXE002 on WSL
  • yet somehow you get EXE002 errors when on WSL

@jku
Copy link
Member

jku commented May 30, 2024

Wild guess: this is because we run ruff inside tox, and somehow this makes the wsl check confused.

If you're interested, you could test installing ruff outside tox and seeing if the issue still appears:

pip install ruff==0.4.4
ruff check tuf examples tests verify_release

@h4l0gen
Copy link
Contributor Author

h4l0gen commented May 30, 2024

@jku still same error :)

Okay i got the issue.

@h4l0gen
Copy link
Contributor Author

h4l0gen commented May 30, 2024

The thing is, I am using the python-tuf directory in WSL from the Windows host, which leads to a weird problem, and hence the WSL check is not passing. I tried running it by creating the python-tuf directory directly in the WSL environment, and it shows no errors.

This really annoying 😓, ruff should only check that from where directory got access. More or less that's ruff cons. IMO we should really document it with note for WSL users. WDYT? @jku

@jku
Copy link
Member

jku commented May 30, 2024

I would usually rather avoid the failure than document it... often documenting workarounds is pointless since people won't find the documentation when they hit the issue.

The thing is, I am using the python-tuf directory in WSL from the Windows host, which leads to a weird problem, and hence the WSL check is not passing

looking at the sources that shouldn't affect things: https://github.com/TheLarkInn/is-wsl/blob/main/src/lib.rs, quite strange.

Anyway, no need to spend a lot of time on this. If you'd like to document a workaround and have found a reasonable place to do it, a PR is welcome. Thanks for testing

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

No branches or pull requests

2 participants