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

cache-dir in configfiile should be relative to that configfile #7958

Closed
woutervh opened this issue Oct 14, 2023 · 1 comment · Fixed by #7962
Closed

cache-dir in configfiile should be relative to that configfile #7958

woutervh opened this issue Oct 14, 2023 · 1 comment · Fixed by #7962
Assignees
Labels
bug Something isn't working

Comments

@woutervh
Copy link

using ruff 0.0.292

in my projects's pyproject.toml, I configure the cache-dir

[tool.ruff]
# ruff searches for settings in the target-dir and up
# https://beta.ruff.rs/docs/configuration/
cache-dir = "var/cache/ruff"  # relative to $PWD

when setting a relative path in pyproject.toml,
the setting should be relative to that pyproject.toml-file.

however, ruff takes it relative to the $PWD, which does not make sense in a configfile.

when I run ruff from my project-directory, it creates cache-dirs in every location I run ruff from:

pyproject.toml

docs/
    conf.py
    var/cache/ruff/
src/
    foo/
         var/cache/ruff
        __init__

tests/
    conftest.py
    var/cache/ruff/

var/cache/ruff/
@charliermarsh
Copy link
Member

I don't think it should be relative to the configuration file in all cases (though it's probably not worth going into why), but it should be relative to the "project root" which is typically the directory containing the configuration file.

In the above case, we should be choosing the top-level directory as the project root in all cases, and so using that same top-level var/cache/ruff/, so seems like a bug.

@charliermarsh charliermarsh self-assigned this Oct 14, 2023
@charliermarsh charliermarsh added the bug Something isn't working label Oct 14, 2023
charliermarsh added a commit that referenced this issue Oct 14, 2023
## Summary

Unlike other filepath-based settings, the `cache-dir` wasn't being
resolved relative to the project root, when specified as an absolute
path.

Closes #7958.
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.

2 participants