Repository navigation
fix(clean): keep PDM's installed packages and project plugins - #2237
Merged
Merged
Conversation
The User app cache sweep removes each folder under ~/Library/Caches as a whole, and nothing kept ~/Library/Caches/pdm, PDM's cache root on macOS. With install.cache on, PDM installs each wheel once under packages/ and project environments symlink into it by default, so after mo clean every installed file in those environments pointed at a file that no longer existed. plugins/ holds what `pdm install --plugins` installed for each project, and PDM skips loading them without a message once the folder is gone. PDM's docs warn that deleting the cache by hand may break projects, and `pdm cache clear` keeps the packages still in use and never touches plugins/. pdm/packages* and pdm/plugins* join the hard-safety whitelist beside Poetry's virtualenvs, the renv cache and pnpm dlx. Refs tw93#2236
Whitelisting pdm/packages* and pdm/plugins* also protects their parent, which takes the whole pdm root out of the generic ~/Library/Caches sweep and its rebuildable caches with it. Name those in clean_dev_python, as Poetry's artifacts and cache already are: hashes, http, wheels and metadata, the folders `pdm cache clear` empties. Refs tw93#2236
A new clean_dev_caches case runs the real clean_user_essentials and clean_dev_python in dry and real mode with a custom whitelist saved, so only the hard-safety list can keep the PDM folders. A cached package and a project plugin must survive both runs, the http and wheels caches must go in the real run and stay in the dry run, and an ordinary cache root is the positive control. Without the whitelist rows the sweep takes the pdm root (PACKAGES_LOST), and without the named caches nothing cleans them (HTTP_KEPT). Refs tw93#2236
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2236
The
User app cacherow inclean_user_essentialsremoves each folder under~/Library/Cachesas a whole (lib/clean/user.sh:343-388), and nothing kept~/Library/Caches/pdm, PDM's cache root on macOS. Two of its folders hold code PDM runs from:packages/: withpdm config install.cache on, PDM installs each wheel once there, and project environments symlink into it by default (install.cache_method). Aftermo clean, every installed file in those environments pointed at a file that no longer existed. PDM's docs warn that "Manually deleting the caches from disk may break some projects on the system".plugins/:pdm install --pluginsinstalls each project's plugins there, and PDM skips loading them without a message once the folder is gone.PDM's own
pdm cache clearkeeps the packages still in use and never touchesplugins/. This PR follows the Poetry, renv and pnpm dlx shape (c32c7274):lib/core/base.sh:pdm/packages*andpdm/plugins*joinSAFETY_WHITELIST_PATTERNS, so they hold even after a user saves a custom whitelist. Whitelisting a nested path also protects its parent, which takes the wholepdmroot out of the generic sweep.lib/clean/dev.sh:clean_dev_pythonnames the rebuildable siblings, the onespdm cache clearempties (hashes,http,wheels,metadata), in aPDM cacherow, as it already does for Poetry'sartifactsandcache. The developer tools section runs on everymo clean, so that space is still reclaimed.What the sweep used to take and nothing cleans now: PDM's small bookkeeping files at the root (
use_cache.json,pip.whl,.compat_libs/,self-check/), whichpdm cache cleardoes not clean either.Safety Review
mo cleanno longer removes~/Library/Caches/pdmas a whole. It keepspackages/andplugins/and cleanshashes/,http/,wheels/andmetadata/from the developer tools section. Nothing outside the PDM root is swept differently.$HOME/Library/Caches/pdm/packages*and$HOME/Library/Caches/pdm/plugins*.pdm cache clearempties, which the generic sweep already removed. TheWhitelist: N corecount thatmo cleanprints grows by two.Tests
./scripts/check.sh,./scripts/test.shvia GitHub Actions CI on this PR)tests/clean_dev_caches.bats:PDM installs and project plugins survive the cache sweep while PDM caches are still cleaned, next to the pnpm dlx case it follows. It runs the realclean_user_essentialsandclean_dev_pythonin dry and real mode with a custom whitelist saved, so only the hard-safety list can keep the PDM folders. A cached package and a project plugin must survive both runs, thehttpandwheelscaches must go in the real run and stay in the dry run, and anordinary-appcache root is the positive control.pip3andrun_with_timeoutare stubbed as in the Jupyter and Yarn Berry cases oftests/clean_developer_state.bats, since/usr/bin/pip3can open the Command Line Tools dialog.Read against
main: without the rows,is_path_whitelistedandshould_protect_pathhold nothing for thepdmroot and the sweep takes it (PACKAGES_LOST); with the rows but without thedev.shline, nothing cleans the caches (HTTP_KEPT).Commits:
2fb598edfix(clean): keep PDM's installed packages and project plugins88cc0be2fix(clean): clean the PDM caches that pdm cache clear empties7f3fdb95test(clean): cover PDM installs and plugins in the cache sweepSafety-related changes
~/Library/Caches/pdm/packagesand~/Library/Caches/pdm/pluginsagainst removal, including under a custom whitelist.