Skip to content

cask/macos: add undeletable container directories - #24357

Merged
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
hyuraku:cask-undeletable-containers
Oct 29, 2026
Merged

MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
hyuraku:cask-undeletable-containers

Conversation

@hyuraku

@hyuraku hyuraku commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

MacOS.undeletable? only matches exact paths in UNDELETABLE_PATHS. So ~/Library/Keychains itself is protected, but a file inside it such as ~/Library/Keychains/login.keychain-db is not. A zap trash: or uninstall delete: stanza, or a pkg uninstall, could still remove it. There was a TODO asking for a way to protect everything under a directory.

This change adds UNDELETABLE_CONTAINERS. undeletable? now also returns true for these directories and any path under them. The list has three directories that are already in UNDELETABLE_PATHS and hold private user data: ~/Library/Keychains (passwords and keys), ~/Library/Messages (message history) and ~/Library/Application Support/com.apple.TCC (privacy permissions).

No official cask is affected as of 2026-10-26. None of the 7,814 casks in homebrew/cask (at Homebrew/homebrew-cask@1d6a12f) point to a path under these directories. The new tests check a path inside ~/Library/Keychains and a sibling path (~/Library/Keychains2/...) to make sure the prefix match does not catch the sibling.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI (Claude Code) assisted in writing the code and tests, and searched homebrew/cask for affected casks. I reviewed the change and ran brew lgtm locally.


@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1e1bb54-e0d7-4539-9a30-b6fd91a870ff
Commits

Reviewing files that changed from the base of the PR and between 844bd0c and d5b65ad.

Files selected for processing: 1
  • Library/Homebrew/cask/macos.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Deletion protection now covers files and folders within keychain, Messages, and privacy-related application data locations, as well as the locations themselves.
    • Paths that resolve through a symlink into a protected location are also covered by deletion protection.
    • Similarly named folders outside those protected locations remain unaffected, so protection applies only to the designated locations and their contents.

The undeletable-path check now tests expanded paths and, when the parent exists, resolved paths. It protects paths within three Library containers and retains checks for explicitly undeletable paths. Specs cover keychain paths and a path reached through a symlink.

Changes: Undeletable paths

Layer / File(s) Summary
Container checks and coverage
Library/Homebrew/cask/macos.rb, Library/Homebrew/test/cask/macos_spec.rb
A private set defines three protected Library containers. undeletable? checks expanded and resolved path candidates for exact matches or containment. Specs check a login keychain path, a similarly named path under Keychains2, and an Applications child reached through a symlink.

Priority: Normal

Merge Risk: Minimal · up to d5b65

The protected directories are checked before uninstall deletion. No merge-blocking risk remains identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the main change: adding undeletable container directories for cask macOS handling.
Description check Passed The description accurately explains the existing limitation, the new container behaviour, the protected directories, test coverage, and validation performed.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3afc3538-0b00-48b6-97f9-743be6eff8f6
Commits

Reviewing files that changed from the base of the PR and between c6069d2 and 9cc6fa1.

Files selected for processing: 2
  • Library/Homebrew/cask/macos.rb
  • Library/Homebrew/test/cask/macos_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/macos.rb Resolved

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good except Code Rabbit comment needs addressed!

@hyuraku
hyuraku force-pushed the cask-undeletable-containers branch from 9cc6fa1 to 844bd0c Compare October 28, 2026 12:47
@hyuraku
hyuraku requested a review from MikeMcQuaid October 28, 2026 12:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e48b33ae-f10e-4a60-b529-c347944f1b85
Commits

Reviewing files that changed from the base of the PR and between 9cc6fa1 and 844bd0c.

Files selected for processing: 2
  • Library/Homebrew/cask/macos.rb
  • Library/Homebrew/test/cask/macos_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/macos.rb Resolved
@MikeMcQuaid

Copy link
Copy Markdown
Member

@hyuraku will review again when all coderabbit comments addressed!

@MikeMcQuaid
MikeMcQuaid removed their request for review October 29, 2026 09:06
@hyuraku
hyuraku force-pushed the cask-undeletable-containers branch from 844bd0c to d5b65ad Compare October 29, 2026 13:48

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 29, 2026
Merged via the queue into Homebrew:main with commit 378acc5 Oct 29, 2026
53 checks passed
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.

2 participants

⌂ 换网址