kyleneideck / BackgroundMusic

Background Music, a macOS audio utility: automatically pause your music, set individual apps' volumes and record system audio.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot uninstall using brew on macOS 14.4

musse opened this issue · comments

Description of the bug
Cannot uninstall after install with brew on macOS 14.4:

brew uninstall background-music
==> Uninstalling Cask background-music
==> Removing launchctl service com.bearisdriving.BGM.XPCHelper
==> Uninstalling packages with sudo; the password may be necessary:
==> Removing files:
/Library/Application Support/Background Music
/Library/Audio/Plug-Ins/HAL/Background Music Device.driver
/usr/local/libexec/BGMXPCHelper.xpc
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
Error: Failure while executing; `/usr/bin/sudo -E -- /bin/launchctl kickstart -kp system/com.apple.audio.coreaudiod` exited with 1. Here's the output:
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted

https://developer.apple.com/documentation/macos-release-notes/macos-14_4-release-notes#Core-Audio

To improve security and stability, using launchctl kickstart -k is no longer permitted for critical system processes. If a process must be forcefully terminated, it is recommended to use kill instead. (123028502)

Steps to reproduce

  1. Install with brew;
  2. Try to uninstall with brew.

Versions

Please complete the following information.

  • Background Music: 0.4.0
  • macOS: Sonoma 14.4

I see the PR to fix this in homebrew-cask is merged, but doing brew update does not seem to fix this issue, is anything else necessary?

@DamianPereira Even after the homebrew-cask fix was merged, there was a "cached" copy of the background-music.rb file (I don't remember the exact path), I had to manually edit it to match the fixed file to be able to uninstall it.

Thank you! I'll check it out.

Similar issue, also happening with ExistentialAudio/BlackHole

$ brew uninstall -f background-music
==> Uninstalling Cask background-music
==> Removing launchctl service com.bearisdriving.BGM.XPCHelper
==> Uninstalling packages with sudo; the password may be necessary:
==> Removing files:
/Library/Application Support/Background Music
/Library/Audio/Plug-Ins/HAL/Background Music Device.driver
/usr/local/libexec/BGMXPCHelper.xpc
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
Error: Failure while executing; `/usr/bin/sudo -E -- /bin/launchctl kickstart -kp system/com.apple.audio.coreaudiod` exited with 1. Here's the output:
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted


$ brew info background-music
==> background-music: 0.4.0
https://github.com/kyleneideck/BackgroundMusic
/opt/homebrew/Caskroom/background-music/0.4.0 (895KB)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/b/background-music.rb
==> Name
Background Music
==> Description
Audio utility
==> Artifacts
BackgroundMusic-0.4.0.pkg (Pkg)
==> Analytics
install: 2,133 (30 days), 7,116 (90 days), 23,090 (365 days)

ok manually editing /opt/homebrew/Caskroom/background-music/.metadata/0.4.0/20231226055056.585/Casks/background-music.rb with the patch did let me uninstall

ok manually editing /opt/homebrew/Caskroom/background-music/.metadata/0.4.0/20231226055056.585/Casks/background-music.rb with the patch did let me uninstall

Can you help me with this? What exactly do I need to edit in this file? I'm just trying to update but that's not possible when I cannot uninstall

@lead0r Is this what you're looking for? https://github.com/Homebrew/homebrew-cask/pull/169322/files

Yes, thank you, that worked!

Can anyone please say how they managed to fix this issue? This is the formula on my Mac that is causing the problem:

cask "background-music" do
  version "0.4.3"
  sha256 "c1c48a37c83af44ce50bee68879856c96b2f6c97360ce461b1c7d653515be7fd"

  url "https://github.com/kyleneideck/BackgroundMusic/releases/download/v#{version}/BackgroundMusic-#{version}.pkg"
  name "Background Music"
  desc "Audio utility"
  homepage "https://github.com/kyleneideck/BackgroundMusic"

  livecheck do
    url :url
    strategy :github_latest
  end

  pkg "BackgroundMusic-#{version}.pkg"

  uninstall_postflight do
    system_command "/usr/bin/killall",
                   args:         ["coreaudiod"],
                   sudo:         true,
                   must_succeed: true
  end

  uninstall launchctl: "com.bearisdriving.BGM.XPCHelper",
            quit:      "com.bearisdriving.BGM.App",
            pkgutil:   "com.bearisdriving.BGM",
            delete:    [
              "/Library/Application Support/Background Music",
              "/Library/Audio/Plug-Ins/HAL/Background Music Device.driver",
              "/usr/local/libexec/BGMXPCHelper.xpc",
            ]

  zap trash: [
    "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist",
    "~/Library/Preferences/com.bearisdriving.BGM.App.plist",
  ]
end

I tried editing it to remove the lines @kyleneideck linked, but then the hash changes and brew won't use it.

Edit: GPT-4 helped! I followed suggestion #2 and it got rid of this app once and for all.

https://copilot.microsoft.com/sl/gqurj7eu7q0

commented

Thanks, followed suggestions by #727 (comment) and #727 (comment) worked.

Thanks, followed suggestions by #727 (comment) and #727 (comment) worked.

Same here. Great find!

A potentially easier solution is to remove the file from the Caskroom and then reinstall it.
This will cause Brew to use the most up-to-date uninstall stanza, instead of the one that was present when the installed version was installed.

Silicon Mac
rm -rfi /opt/homebrew/Caskroom/background-music/

Intel Mac
rm -rfi /usr/local/Caskroom/background-music/

Then reinstall
brew reinstall background-music