cool-easter-32542
02/21/2024, 11:25 PMXDG_CACHE_DIR and/or BLACK_CACHE_DIR env vars automatically(?)
2. writing it to a Pants-managed named/append-only cache
3. disabling it entirely, and just rely on Pants' process level caching
Reproducer:
cd $(mktemp -d)
default_cache_dir=~/Library/Caches/black # or ~/.cache/black, or something else
# WARNING: this is mutates your disk! Check before running
clear_global_cache() {
echo "clearing '$default_cache_dir'"
rm -rf "$default_cache_dir"
}
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.19.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
]
[python]
interpreter_constraints = ["==3.*"]
EOF
echo 'python_sources(name="src")' > BUILD
echo 'a' > file.py
# This bug relates to when black is actually executed, so let's get the Pants caches out of the way
export PANTS_PANTSD=false PANTS_LOCAL_CACHE=false
# BUG 1: writes to cache with default settings
clear_global_cache
pants fmt ::
tree "$default_cache_dir"
# BUG 2: writes to cache even with (attempted) override
tmp_cache_dir="temp-cache"
clear_global_cache
BLACK_CACHE_DIR="$tmp_cache_dir" pants fmt ::
tree "$default_cache_dir"
tree "$tmp_cache_dir"
This sets up pants to run black in two configurations, starting with an empty global/default black cache each time. In both configurations, that global cache is written to:
1. default settings
2. with an explicit override via BLACK_CACHE_DIR
Pants version
2.19.0
OS
macOS
Additional info
N/A
pantsbuild/pantscool-easter-32542
03/05/2024, 11:08 PM