Skip to content

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

@jaraco

Description

@jaraco

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcacheRelated to Ruff cache

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions