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

brew list --cask shows symlinks of renamed packages #18849

Closed
3 tasks done
yochem opened this issue Dec 2, 2024 · 3 comments · Fixed by #18946
Closed
3 tasks done

brew list --cask shows symlinks of renamed packages #18849

yochem opened this issue Dec 2, 2024 · 3 comments · Fixed by #18946
Labels
bug Reproducible Homebrew/brew bug help wanted We want help addressing this

Comments

@yochem
Copy link

yochem commented Dec 2, 2024

brew doctor output

Your system is ready to brew.

Verification

  • My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update twice and am still able to reproduce my issue.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

HOMEBREW_VERSION: 4.4.8
ORIGIN: https://github.com/Homebrew/brew
HEAD: e78a0adb4f260913fffdc956cc8c20fb54109feb
Last commit: 7 days ago
Branch: stable
Core tap JSON: 02 Dec 10:59 UTC
Core cask tap JSON: 02 Dec 10:59 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BUNDLE_USER_CACHE: /Users/yochem/Library/Caches/bundle
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 3.3.6 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: quad-core 64-bit kabylake
Clang: 16.0.0 build 1600
Git: 2.45.0 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 14.7.1-x86_64
CLT: 16.1.0.0.1.1729049160
Xcode: N/A

What were you trying to do (and why)?

List all casks available on my system (to see if some could be removed)

What happened (include all command output)?

$ brew list --cask -1
brave-browser
google-drive
hammerspoon
iterm2-beta
iterm2@beta
itsycal
logi-options+
logi-options-plus
microsoft-auto-update
microsoft-teams
monitorcontrol
spotify
telegram
utm
visual-studio-code
vlc
whatsapp

I thought, oh, I have both logi-options-plus and logo-options+ installed (same with iterm2). Better remove the former:

$ brew uninstall --cask logi-options-plus
Warning: Cask logi-options-plus was renamed to logi-options+.

Oh. I don't want to remove that one.

Let's check:

$ ls -l /usr/local/Caskroom
drwxr-xr-x 4 yochem admin 128 2024-07-20  brave-browser/
drwxr-xr-x 4 yochem admin 128 2024-05-09  google-drive/
drwxr-xr-x 4 yochem admin 128 2024-11-29  hammerspoon/
lrwxr-xr-x 1 yochem admin  11 2024-07-20  iterm2-beta -> 'iterm2@beta'/
drwxr-xr-x 4 yochem admin 128 2024-07-20 'iterm2@beta'/
drwxr-xr-x 4 yochem admin 128 2024-05-09  itsycal/
drwxr-xr-x 4 yochem admin 128 2024-10-25  logi-options+/
lrwxr-xr-x 1 yochem admin  13 2024-09-30  logi-options-plus -> logi-options+/
drwxr-xr-x 4 yochem admin 128 2024-05-09  microsoft-auto-update/
drwxr-xr-x 4 yochem admin 128 2024-05-09  microsoft-teams/
drwxr-xr-x 4 yochem admin 128 2023-09-17  monitorcontrol/
drwxr-xr-x 4 yochem admin 128 2024-05-09  spotify/
drwxr-xr-x 4 yochem admin 128 2024-05-09  telegram/
drwxr-xr-x 4 yochem admin 128 2024-05-09  utm/
drwxr-xr-x 4 yochem admin 128 2024-05-09  visual-studio-code/
drwxr-xr-x 4 yochem admin 128 2024-02-18  vlc/
drwxr-xr-x 4 yochem admin 128 2024-05-09  whatsapp/

Ah, symlinks, and the brew list command probably just lists the directory.

What did you expect to happen?

brew list --cask shows exactly which casks I have installed and ignores links to the same cask.

Step-by-step reproduction instructions (by running brew commands)

I'm unsure if you can still install casks with their old name, so to fake this situation:


$ brew install --cask logi-options+
$ ln -s $(brew --prefix)/Caskroom/logi-options+ $(brew --prefix)/Caskroom/sym-test
$ brew list --cask -1
logi-options+
sym-test
@yochem yochem added the bug Reproducible Homebrew/brew bug label Dec 2, 2024
@yochem
Copy link
Author

yochem commented Dec 2, 2024

Probably need to add a symlink check here.

@MikeMcQuaid
Copy link
Member

Probably need to add a symlink check here.

@yochem Could you try and open a pull request? This document should help and we're happy to walk you through anything else.

Thanks!

@MikeMcQuaid MikeMcQuaid added the help wanted We want help addressing this label Dec 3, 2024
vidishanevatia pushed a commit to vidishanevatia/brew that referenced this issue Dec 17, 2024
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
@vidishanevatia
Copy link

The documentation was super helpful, I tested it with your reproduction instruction and it works just fine. Opened a PR above. @yochem

github-merge-queue bot pushed a commit that referenced this issue Dec 17, 2024
Fixes  #18849 :  fix duplicate casks when symlinks exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/brew bug help wanted We want help addressing this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants