Skip to content

fix: add Yarn v1 global cache cleanup#780

Merged
tw93 merged 1 commit intotw93:mainfrom
khisby:fix/add-yarn-v1-cache-cleanup
Apr 23, 2026
Merged

fix: add Yarn v1 global cache cleanup#780
tw93 merged 1 commit intotw93:mainfrom
khisby:fix/add-yarn-v1-cache-cleanup

Conversation

@khisby
Copy link
Copy Markdown
Contributor

@khisby khisby commented Apr 22, 2026

Summary

  • Add cleanup for Yarn v1 global cache at ~/Library/Caches/Yarn/ in clean_dev_npm()
  • The existing ~/.yarn/cache/* only covers Yarn v2+ (Berry), missing the Yarn v1 (Classic) cache path on macOS
  • This cache can grow to several GB over time (5.9 GB in my case) and is never cleaned by mo clean

Safety Review

  • Does this change affect cleanup behavior? Yes — adds one new safe_clean target to the existing clean_dev_npm() function.
  • Does this change affect path validation, protected directories, symlink handling, sudo boundaries, or release/install integrity? No. It uses the same safe_clean mechanism as all other cache paths, which respects whitelist and dry-run modes.
  • The new path ~/Library/Caches/Yarn/* is a well-known macOS cache directory used exclusively by Yarn v1. It contains downloaded package tarballs that are re-fetched on demand, so deletion is safe and non-destructive.

Tests

  • Verified ~/Library/Caches/Yarn/ exists on a macOS machine that has used Yarn v1
  • Confirmed mo clean --dry-run does not currently list this path
  • Confirmed the change correctly adds it to the dry-run output after patching
  • Verified whitelist and --dry-run are respected (uses existing safe_clean helper)

Safety-related changes

  • None. Uses the same safe_clean function as all other cache cleanup targets.

Yarn v1 stores its global cache at ~/Library/Caches/Yarn/ on macOS,
which is separate from the ~/.yarn/cache/ path used by Yarn v2+.
This cache can grow to several gigabytes and is not cleaned by
`yarn cache clean` when Yarn v2+ is the active version.
@khisby khisby requested a review from tw93 as a code owner April 22, 2026 08:56
@tw93 tw93 merged commit 4eb54a6 into tw93:main Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants