Skip to content

fix(cask): replace uninstall_postflight with uninstall_postflight_steps - #73

Closed
lesleslie wants to merge 1 commit into
redis-stack:masterfrom
lesleslie:fix/uninstall-postflight-steps-deprecation
Closed

lesleslie wants to merge 1 commit into
redis-stack:masterfrom
lesleslie:fix/uninstall-postflight-steps-deprecation

Conversation

@lesleslie

Copy link
Copy Markdown

Summary

Fixes the deprecation warning printed on every brew uninstall --cask redis-stack-server:

Warning: Calling `uninstall_postflight` is deprecated! Use `uninstall_postflight_steps` instead.
Please report this issue to the redis-stack/homebrew-redis-stack tap (not Homebrew/* repositories), or even better, submit a PR to fix it:
  /usr/local/Homebrew/Library/Taps/redis-stack/homebrew-redis-stack/Casks/redis-stack-server.rb:43

What changed

Replaced the deprecated uninstall_postflight block with the structured uninstall_postflight_steps block. The new DSL requires literal arguments and the curated step set — no arbitrary Ruby.

Original (deprecated) Replacement (steps DSL)
binaries.each + File.exist? + File.readlink().include?("redis-stack") one remove"{{HOMEBREW_PREFIX}}/bin/<name>", symlink_target_contains: "redis-stack" per binary
Dir[".../*.so"].each + File.basename + File.delete remove "{{HOMEBREW_PREFIX}}/lib/*.so", symlink_target_contains: "redis-stack"
Ruby interpolation #{HOMEBREW_PREFIX} template substitution {{HOMEBREW_PREFIX}} (required inside steps blocks)

Behavior is preserved: only symlinks whose target references the caskroom are removed, leaving any user-installed binaries or libraries at the same path untouched.

Follow-up (not in this PR)

The matching postflight block on the install side has the same deprecation:

postflight do
  FileUtils.mkdir_p confdir
  FileUtils.cp(src, conffile) unless File.exist?(conffile)
  File.symlink(...) unless File.exist?(dest)
  Dir[".../*.so"].each { File.symlink(...) }
end

Migrating it to postflight_steps is a larger refactor (FileUtils.cp with an unless-exists guard, File.symlink loops, Dir[] glob → source_glob:) and would change the install-time behavior enough that it deserves its own PR + test cycle. Happy to send that as a follow-up once this lands.

The legacy `uninstall_postflight` block is deprecated and prints a warning
on every uninstall:

    Warning: Calling uninstall_postflight is deprecated! Use
    uninstall_postflight_steps instead.

`uninstall_postflight_steps` requires structured step calls with literal
arguments — no arbitrary Ruby. This commit:

* swaps the deprecated block for `uninstall_postflight_steps`
* replaces `binaries.each` / `File.readlink().include?("redis-stack")`
  with one `remove ... symlink_target_contains: "redis-stack"` per binary
* replaces `Dir[...] / File.basename / File.delete` with a single
  `remove ".../lib/*.so", symlink_target_contains: "redis-stack"`
* uses the `{{HOMEBREW_PREFIX}}` template syntax (steps-DSL requires this
  in place of Ruby interpolation `#{HOMEBREW_PREFIX}`)

Behavior is preserved: only symlinks whose target references the caskroom
are removed, leaving any user-installed binaries/libraries at the same
path untouched.

The `postflight` block on the install side is also deprecated for the
same reason but requires a larger refactor (Dir[] glob, File.symlink
loops, FileUtils.cp unless-exist); left for a follow-up.
@lesleslie lesleslie closed this Oct 3, 2026
@lesleslie
lesleslie deleted the fix/uninstall-postflight-steps-deprecation branch October 3, 2026 18:22
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.

1 participant