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

Add ability to globally disable caching #12706

Closed
TJNII opened this issue Feb 22, 2024 · 3 comments
Closed

Add ability to globally disable caching #12706

TJNII opened this issue Feb 22, 2024 · 3 comments

Comments

@TJNII
Copy link

TJNII commented Feb 22, 2024

Is your feature request related to a problem? Please describe.

While backing up my system today I noticed Rubocop writing into ~/.cache. I find this behavior undesirable as I try to keep my code and it's dependencies tightly contained in working directories, it's never pleasant to find when a tool escapes where I put it and begins writing to other paths on my filesystem. I found the documentation at https://docs.rubocop.org/rubocop/usage/caching.html, but I was disappointed to see that this option, which writes outside the per-project tree, is currently only settable in per-project config. I'm not looking forward to having to remember to turn this off on every project I work on.

Describe the solution you'd like

As Rubocop has is writing outside the bounds of the project tree, please add a config file that reads from outside the project tree where environmental options like this can be globally specified. For this case I'm not seeking any deep configs so a simple read and merge should be sufficient.

Describe alternatives you've considered

Per https://docs.rubocop.org/rubocop/usage/caching.html there aren't any. chmod 000 ~/.cache/rubocop_cache I guess?

@TJNII
Copy link
Author

TJNII commented Feb 22, 2024

Per https://docs.rubocop.org/rubocop/configuration.html reading from ~/.rubocop.yml is supported, but if $(pwd)/.rubocop.yml exists it will not be loaded. The behavior added in #8314 appears to be at odds with with the behavior I want.

I maintain my assertion that if Rubocop is going to write outside the project tree, then it must accept config from outside the project tree as well. Perhaps an ENV var? Per https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cache_config.rb#L8 setting RUBOCOP_CACHE_ROOT to an empty string will not disable it.

@jonas054
Copy link
Collaborator

What about the --cache false command line option? Have you considered that?

@TJNII
Copy link
Author

TJNII commented Feb 27, 2024

I have, but the spirit of the request is for when I forget about this behavior and don't remember I need to add a flag or tune the project config file. I'm looking for something I can set in my home directory or bashrc to configure Rubocop to stay within the project tree. The problem with a command line argument is I often run Rubocop from Make or bundler, and bundler (apparently) doesn't use bash aliases so I can't alias rubocop="rubocop --cache-false" in my .bashrc.

I actually just realized that there is a simple, supported solution to this: My grouse isn't with the caching itself, it's with the default cache directory being outside the project tree. RUBOCOP_CACHE_ROOT supports relative paths. RUBOCOP_CACHE_ROOT='./tmp/rubocop/cache' works.

As this caching feature has been around for a while and nobody else is asking for a global disable option I think we can close this. I found a solution to my concern.

And for the record chmod 000 ~/.cache/rubocop_cache does work, but that's only good for making sure ~/.cache/rubocop_cache is never written and reminding that the project config needs updated via the error. It's heavy handed, but workable.

@TJNII TJNII closed this as completed Feb 27, 2024
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