You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Changes introduced to cache key calculations by #4096 made Black unusable with cache dir located on eCryptfs container which limits the maximum file names to 143 characters. eCryptfs is usually used to protect user home directories, where the default .cache/black location is created.
#4096 added another sha256 hexdigest to the cache file names which now overflow the 143 characters limit.
If the directory is not your home directory, set BLACK_CACHE_DIR so that it's pointing to the mounted unencrypted directory.
Then take this code.py:
42
and try to format it twice, because the first call doesn't seem to create cache:
$ export BLACK_CACHE_DIR=/optionally/set/path/to/cache/on/mounted/ecryptf/if/its/not/your/home
$ black file.py
$ black file.py
The resulting error is:
error: cannot format file.py: [Errno 36] File name too long: '/home/rf/black-cache/24.1.0/cache.-.88.1.0.0.0.1.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.0.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.pickle'
Oh no! 💥 💔 💥
1 file failed to reformat.
where /home/rf/black-cache was the value of BLACK_CACHE_DIR in my case.
Expected behavior
Reformat should work despite cache creation issues and/or cache should be reworked, for example by introducing multi-level cache directories if all the current information has to be retained.
Environment
Black's version: 24.1.0
OS and Python version: Linux/python3.11.6
Additional context
Max length of the filename for the given directory can be verified with getconf, for example:
Describe the bug
Changes introduced to cache key calculations by #4096 made Black unusable with cache dir located on eCryptfs container which limits the maximum file names to 143 characters. eCryptfs is usually used to protect user home directories, where the default
.cache/black
location is created.#4096 added another sha256 hexdigest to the cache file names which now overflow the 143 characters limit.
To Reproduce
Set up and mount eCryptfs directory, for example you can follow this guide: https://wiki.archlinux.org/title/ECryptfs#Setup_&_mounting
If the directory is not your home directory, set
BLACK_CACHE_DIR
so that it's pointing to the mounted unencrypted directory.Then take this
code.py
:42
and try to format it twice, because the first call doesn't seem to create cache:
$ export BLACK_CACHE_DIR=/optionally/set/path/to/cache/on/mounted/ecryptf/if/its/not/your/home $ black file.py $ black file.py
The resulting error is:
where
/home/rf/black-cache
was the value ofBLACK_CACHE_DIR
in my case.Expected behavior
Reformat should work despite cache creation issues and/or cache should be reworked, for example by introducing multi-level cache directories if all the current information has to be retained.
Environment
Additional context
Max length of the filename for the given directory can be verified with
getconf
, for example:The text was updated successfully, but these errors were encountered: