Skip to content

brew rm --zap silently fails to remove any files on Linux for all casks #22082

@mologie

Description

@mologie

brew doctor output

$ brew config
HOMEBREW_VERSION: 5.1.7-94-gd667226
ORIGIN: https://github.com/Homebrew/brew
HEAD: d66722647e1bcd1fd4739ed6f5c90f3a5d8b7e41
Last commit: 14 hours ago
Branch: main
Core tap HEAD: da4bd1f444cce9c5712e2cf8d9ef8b565d313c59
Core tap last commit: 12 hours ago
Core tap JSON: 24 Apr 22:24 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_DOWNLOAD_CONCURRENCY: 32
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_MAKE_JOBS: 16
HOMEBREW_NO_EMOJI: set
HOMEBREW_NO_ENV_HINTS: set
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 4.0.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/4.0.3/bin/ruby
CPU: 16-core 64-bit skylake
brClang: 21.1.8
eGit: 2.53.0 => /bin/git
Curl: 8.18.0 => /bin/curl
Kernel: Linux 7.0.0-14-generic x86_64 GNU/Linux
OS: Ubuntu 26.04 LTS (resolute)
Host glibc: 2.43
Host libstdc++: 6.0.35
/usr/bin/gcc: N/A
/usr/bin/ruby: N/A
w dglibc: N/A
gcc@12: N/A
gcc: N/A
xorg: N/A

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have uncommitted modifications to Homebrew/homebrew-cask.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  git -C "/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask" stash -u && git -C "/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask" clean -d -f

Uncommitted files:
  M  Casks/w/winbox.rb

Warning: Some taps are not on the default git origin branch and may not receive
updates. If this is a surprise to you, check out the default branch with:
  git -C $(brew --repo homebrew/cask) checkout

Verification

  • I ran brew update twice and am still able to reproduce my issue.
  • My "brew doctor output" above says Your system is ready to brew or a definitely unrelated Tier message.
  • 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

$ brew config
HOMEBREW_VERSION: 5.1.7-94-gd667226
ORIGIN: https://github.com/Homebrew/brew
HEAD: d66722647e1bcd1fd4739ed6f5c90f3a5d8b7e41
Last commit: 15 hours ago
Branch: main
Core tap HEAD: da4bd1f444cce9c5712e2cf8d9ef8b565d313c59
Core tap last commit: 13 hours ago
Core tap JSON: 24 Apr 22:24 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_DOWNLOAD_CONCURRENCY: 32
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_MAKE_JOBS: 16
HOMEBREW_NO_EMOJI: set
HOMEBREW_NO_ENV_HINTS: set
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 4.0.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/4.0.3/bin/ruby
CPU: 16-core 64-bit skylake
Clang: 21.1.8
Git: 2.53.0 => /bin/git
Curl: 8.18.0 => /bin/curl
Kernel: Linux 7.0.0-14-generic x86_64 GNU/Linux
OS: Ubuntu 26.04 LTS (resolute)
Host glibc: 2.43
Host libstdc++: 6.0.35
/usr/bin/gcc: N/A
/usr/bin/ruby: N/A
glibc: N/A
gcc@12: N/A
gcc: N/A
xorg: N/A

What were you trying to do (and why)?

I am developing Linux support for the winbox cask, but found that the zap command is non-functional across all casks. It claims to trash files, but doesn't.

This behavior is reproducible for me on a near-stock Ubuntu 26.04 on all casks.

After digging a bit, it seems trash_paths of abstract_uninstall.rb simply does not implement trashing files on Linux. It always calls into a Swift script. Not sure I read that right, but if it's not implemented, that explains the issue.

What happened (include all command output)?

During development of Homebrew/homebrew-cask#261129, I found that running brew rm --zap --cask --force winbox prints that it would trash files, but it actually does nothing. Exact commands below in steps to reproduce, but you may use any Cask to reproduce this.

What did you expect to happen?

Expected behavior would be to actually delete/trash files it prints to delete. If this fails for some reason, I'd at least expect an error message of some kind, but the tool and return code indicates success.

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

$ XDG_DATA_HOME=/tmp/mikrotik/data brew rm --zap --cask winbox
==> Unlinking Binary '/home/linuxbrew/.linuxbrew/bin/winbox'
==> Dispatching zap stanza
==> Trashing files:
/tmp/mikrotik/data/MikroTik/WinBox
==> Removing all staged versions of Cask 'winbox'

$ l /tmp/mikrotik/data/MikroTik/WinBox/settings.cfg.viw2 
-rw-rw-r-- 1 tri tri 273 Apr 25 11:35 /tmp/mikrotik/data/MikroTik/WinBox/settings.cfg.viw2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions