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

cleanup: remove broken symlink for uninstalled migrated Casks #16872

Merged
merged 1 commit into from Mar 31, 2024

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Mar 10, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Draft to rebase after #16871

Currently, if there is a cask_rename and user does brew migrate <cask> then brew uninstall <cask>, we leave behind a broken symlink in the Caskroom.

As far as I can tell, this requires a manual deletion. --prune=all / --prune-prefix doesn't handle Caskroom.

Not sure if possible to handle during brew uninstall so just went with adding additional symlink check in brew cleanup. I didn't do any empty directory removal and only left logic as direct symlinks inside Caskroom.

@cho-m cho-m force-pushed the cleanup-cask-broken-symlinks branch from 5d52045 to 3ddc196 Compare March 21, 2024 21:56
@cho-m cho-m marked this pull request as ready for review March 21, 2024 21:56
@cho-m
Copy link
Member Author

cho-m commented Mar 21, 2024

Actually looks like logic may exist but it doesn't seem to work for me:

# Remove symlinks for renamed casks if they are now broken.
@cask.old_tokens.each do |old_token|
old_caskroom_path = Caskroom.path/old_token
FileUtils.rm old_caskroom_path if old_caskroom_path.symlink? && !old_caskroom_path.exist?
end

EDIT: It might be due to loading the Cask file that was used for installation. Loading Cask from tap has renames.

@MikeMcQuaid
Copy link
Member

It might be due to loading the Cask file that was used for installation.

This seems likely.

IMO we should refactor the way this cask file storing/loading works so instead of storing the cask file sometimes and JSON other times: we store the minimum viable amount of JSON needed for e.g. uninstalling the cask.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Good catch, thanks @cho-m!

@MikeMcQuaid MikeMcQuaid merged commit 87bf4af into Homebrew:master Mar 31, 2024
25 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.

None yet

3 participants