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

EXE002 doesn't update when the file permissions change #5726

Closed
tom-mcdermott-morse opened this issue Jul 13, 2023 · 1 comment · Fixed by #5901
Closed

EXE002 doesn't update when the file permissions change #5726

tom-mcdermott-morse opened this issue Jul 13, 2023 · 1 comment · Fixed by #5901
Assignees
Labels
bug Something isn't working

Comments

@tom-mcdermott-morse
Copy link

`
spon> ruff --version
ruff 0.0.277
spon> touch fake.py
spon> chmod +x fake.py
spon> ruff check --select EXE .
fake.py:1:1: EXE002 The file is executable but no shebang is present
Found 1 error.
spon> chmod -x fake.py
spon> ls -l
total 0
-rw-rw-r-- 1 spon spon 0 Jul 13 16:50 fake.py
spon> ruff check --select EXE .
fake.py:1:1: EXE002 The file is executable but no shebang is present
Found 1 error.
spon> ruff check --select EXE -n .
spon> ruff check --select EXE .
fake.py:1:1: EXE002 The file is executable but no shebang is present
Found 1 error.

`
I'd expect ruff to work here without explicit cache manipulation

@MichaReiser MichaReiser added the bug Something isn't working label Jul 13, 2023
@charliermarsh
Copy link
Member

Previous PR that fixed this, before we refactored the cache: #3104. In that case, we added the file permissions (for each file) to the cache key.

@zanieb zanieb self-assigned this Jul 13, 2023
zanieb added a commit that referenced this issue Jul 25, 2023
Reimplements #3104
Closes #5726

Note that we will generate the hash for a cache key twice in normal
operation. Once to check for the cached item and again to update the
cache. We could optimize this by generating the hash once in
`diagnostics::lint_file` and passing the `u64` into `get` and `update`.
We'd probably want to wrap it in a `CacheKeyHash` enum for type safety.

## Test plan

Unit tests for Windows and Unix.

Manual test with case from issue

```
❯ touch fake.py
❯ chmod +x fake.py
❯ ./target/debug/ruff --select EXE fake.py
fake.py:1:1: EXE002 The file is executable but no shebang is present
Found 1 error.
❯ chmod -x fake.py
❯ ./target/debug/ruff --select EXE fake.py
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants