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

Access Denied error due to race saving cache file on Windows #12284

Closed
jaraco opened this issue Jul 10, 2024 · 3 comments · Fixed by #12302
Closed

Access Denied error due to race saving cache file on Windows #12284

jaraco opened this issue Jul 10, 2024 · 3 comments · Fixed by #12302
Assignees
Labels
bug Something isn't working cache Related to Ruff cache

Comments

@jaraco
Copy link
Contributor

jaraco commented Jul 10, 2024

In pypa/setuptools#4467 and businho/pytest-ruff#28 and this Discord convo, I've captured an issue that's recently become apparent when pytest-ruff started failing on an exit code 2 (pytest-ruff 0.4).

In a test environment utilizing pytest-ruff and pytest-xdist, many tests will be run in parallel and since pytest-ruff passes each file to a separate ruff invocation, there may potentially be many instances of ruff launched for the same root directory and settings (and thus cache key).

As a result, Ruff will fail and exit with code 2 with the following output:

            Cause: Failed to rename temporary cache file to D:\a\setuptools\setuptools\.ruff_cache\0.5.1\13567325068112760734
            Cause: failed to persist temporary file: Access is denied. (os error 5)
            Cause: Access is denied. (os error 5)

Since it's a cache file, maybe the failure should be ignored, or maybe it could be retried.

At the very least, catching this error and exiting with a distinct exit code would allow tools like pytest-ruff to ignore the failure.

@jaraco
Copy link
Contributor Author

jaraco commented Jul 10, 2024

My guess is the same behavior is happening on Linux too, but the file system allows the race to be resolved by replacing the file. Maybe there's a Windows file operation that's comparable.

@dhruvmanila dhruvmanila added bug Something isn't working cache Related to Ruff cache labels Jul 11, 2024
@charliermarsh
Copy link
Member

Yeah my guess is we're trying to replace the file while it's being read.

@charliermarsh charliermarsh self-assigned this Jul 12, 2024
@charliermarsh
Copy link
Member

My vote would be to make these non-fatal, and warn. Cache errors should generally be non-fatal IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cache Related to Ruff cache
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants