Skip to content

Commit

Permalink
cmd/list: fix duplicate casks when symlinks exist
Browse files Browse the repository at this point in the history
When a cask is renamed (e.g. logi-options-plus to logi-options+),
Homebrew creates a symlink in the Caskroom directory. Currently,
`brew list --cask` shows both the original and symlinked cask as
separate entries. This patch modifies the listing logic to resolve
symlinks and show only unique casks.

Fixes Homebrew#18849
  • Loading branch information
“Vidisha committed Dec 17, 2024
1 parent d43fa1f commit 4403280
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Library/Homebrew/cmd/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,15 @@ def filtered_list
sig { void }
def list_casks
casks = if args.no_named?
Cask::Caskroom.casks
cask_paths = Cask::Caskroom.path.children.map do |path|
if path.symlink?
real_path = path.realpath
real_path.basename.to_s
else
path.basename.to_s
end
end.uniq
cask_paths.map { |name| Cask::CaskLoader.load(name) }
else
filtered_args = args.named.dup.delete_if do |n|
Homebrew.failed = true unless Cask::Caskroom.path.join(n).exist?
Expand Down

0 comments on commit 4403280

Please sign in to comment.