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

eCryptfs incompatibility introduced in 24.1.0 #4174

Closed
florczakraf opened this issue Jan 26, 2024 · 3 comments
Closed

eCryptfs incompatibility introduced in 24.1.0 #4174

florczakraf opened this issue Jan 26, 2024 · 3 comments
Labels
T: bug Something isn't working

Comments

@florczakraf
Copy link

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:

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:

$ getconf NAME_MAX ~/black-cache
143
$ getconf NAME_MAX /
255
@florczakraf florczakraf added the T: bug Something isn't working label Jan 26, 2024
@RedGuy12
Copy link
Contributor

Looks like a duplicate of #4172?

@florczakraf
Copy link
Author

Oh, indeed, it wasn't there when I started creating this issue ;)

@JelleZijlstra
Copy link
Collaborator

Closing as duplicate, thanks for the detailed writeup.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants