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

Pylint prints error about cache files in fresh environment with pylint 2.10.2 #4900

Closed
GeZZu opened this issue Aug 23, 2021 · 7 comments · Fixed by #4988
Closed

Pylint prints error about cache files in fresh environment with pylint 2.10.2 #4900

GeZZu opened this issue Aug 23, 2021 · 7 comments · Fixed by #4988
Assignees
Labels
Milestone

Comments

@GeZZu
Copy link

GeZZu commented Aug 23, 2021

Bug description

When I run pylint for my code in fresh environment (in build server), pylint tells me that it's not able to create cache directory (and files) to %localappdata%\pylint\pylint\Cache (Unable to create directory [full path]).

Nevertheless I get the expected linting results written to a file.

I was able to reproduce the issue in my environment by upgrading pylint to 2.10.2 and removing pylint folder from %localappdata% and .pylint.d folder from %userprofile%

If I have .pylint.d folder in %userprofile%, I'll get message, which tells that .pylint.d is obsolete and PYLINTHOME now points to %localappdata%\pylint\pylint\Cache. In that case the cache files are stored properly to PYLINTHOME.

Everything also works in the fresh environment if I create the cache folder %localappdata% before running pylint.

Command used

pylint file.py

Pylint output

Unable to create directory

Expected behavior

No error messages

Pylint version

pylint 2.10.2
astroid 2.7.2
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Windows 10

@GeZZu GeZZu added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 23, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 23, 2021
@Pierre-Sassoulas Pierre-Sassoulas modified the milestone: 2.10.3 Aug 23, 2021
@forana
Copy link

forana commented Aug 23, 2021

Seeing this as well - this has broken our CI.

@Pierre-Sassoulas
Copy link
Member

I wonder if we should try to create a cache in the local directory if we can't access the XDG_CACHE, in continuous integration we can't expect write access to the standard cache, so maybe using the local dir would be better.

@GeZZu
Copy link
Author

GeZZu commented Aug 24, 2021

I don't know how things have been implemented under the hood, but I would assume that write access is not the issue, you just need to verify that the cache folder exists and create it and all it's parents if it doesn't exist before trying to write anything to there.

I believe that the "Unable to create directory" message comes as it tries to create only the Cache folder, but not it's parents, which are also missing.

It also seems that the cache files are properly written to Cache folder if .pylint.d folder exists. So somewhere the code is cabable of being able to create the Cache folder and all it's parent's properly.

Anyway I'm totally fine with local cache dir also, if the normal cache dir permissions doesn't allow accessing it.

@DanielNoord
Copy link
Collaborator

DanielNoord commented Sep 9, 2021

Based on a @GeZZu's comment and my own testing I assumed changing the function to os.makedirs instead of os.mkdir could solve the issue as the former also creates any necessary parent directories.
From my testing this seems to solve the issue, but I can't test on a windows computer so somebody else might also want to check this!

See DanielNoord#13 for a version with that change.
It can be installed by running:
pip install git+git://github.com/DanielNoord/pylint.git@cache-directory#egg=pylint -U

@GeZZu
Copy link
Author

GeZZu commented Sep 10, 2021

Thanks.
Your change fixed it.

@DanielNoord
Copy link
Collaborator

Good to hear! Going to make a PR!

DanielNoord added a commit to DanielNoord/pylint that referenced this issue Sep 10, 2021
By changing the function used to create the cache from ``os.mkdir``
to ``os.makedirs`` we now handle non-existing parent directories
correctly.
This closes pylint-dev#4900
Pierre-Sassoulas pushed a commit that referenced this issue Sep 10, 2021
By changing the function used to create the cache from ``os.mkdir``
to ``os.makedirs`` we now handle non-existing parent directories
correctly.
This closes #4900
@trampgeek

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants