homebrew-cask icon indicating copy to clipboard operation
homebrew-cask copied to clipboard

update(blackhole-2ch): kickstart "com.apple.audio.coreaudiod" Operation not permitted

Open emindeniz99 opened this issue 2 years ago • 18 comments

Verification

Description of issue

> brew upgrade
==> Casks with 'auto_updates true' or 'version :latest' will not be upgraded; pa
==> Upgrading 1 outdated package:
blackhole-2ch 0.5.0 -> 0.6.0
==> Upgrading blackhole-2ch
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/aa21378
Already downloaded: /Users/emin/Library/Caches/Homebrew/downloads/304ebd2343c2ca204b80ca5b123eb22ec1c53dd65057dfc453387679f01f7bcf--blackhole-2ch.rb
==> Downloading https://existential.audio/downloads/BlackHole2ch-0.6.0.pkg
Already downloaded: /Users/emin/Library/Caches/Homebrew/downloads/094ac75837aa76e51e9defa1f6623144c5a3b223a1b426cf5ddb42c224e70c4a--BlackHole2ch-0.6.0.pkg
==> Uninstalling packages with sudo; the password may be necessary:
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
==> Purging files for version 0.6.0 of Cask blackhole-2ch
Error: blackhole-2ch: 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

Command that failed

brew upgrade

Output of command with --verbose --debug

I edited manually rb file so that remove kickstart coreaudiod command. https://github.com/kyleneideck/BackgroundMusic/issues/727#issuecomment-2032782997

Output of brew doctor and brew config

-

Output of brew tap

-

Related Issues

https://github.com/kyleneideck/BackgroundMusic/issues/727#issuecomment-2032782997

emindeniz99 avatar Apr 17 '24 13:04 emindeniz99

I have the same error and found this. Core Audio - Known Issues

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)

Solution: With OS X Sonoma 14.4 update there is no rights to relaunch coreaudiod - https://forums.developer.apple.com/forums/thread/748228?answerId=784882022#784882022

sudo killall coreaudiod

klaushardt avatar Apr 17 '24 17:04 klaushardt

Yes, I patched the Cask files for blackhole-[2|16|64]ch to account for this after it was raised to our attention last month.

We had a discussion the other day about the solution, and someone was kind enough to write a small patch script - https://github.com/orgs/Homebrew/discussions/5291

krehel avatar Apr 17 '24 17:04 krehel

Thank you @klaushardt and @krehel, I solved my problem with removing the uninstall cask script from local file and kill coreaudiod manually.

I didn't search the issue in discussions, sorry for my mistake.

Manual editing is required for all users. Is it correct because there is not any method to update installed cask in local homebrew metadata?

emindeniz99 avatar Apr 17 '24 17:04 emindeniz99

@emindeniz99 No there isn't, because the uninstall process can often change over time, so we use the version that matches the currently installed version. If you were to remove the cask's directory from the Caskroom, and use brew reinstall the latest uninstall script would be used instead.

bevanjkay avatar Apr 17 '24 23:04 bevanjkay

I uninstalled the old version by manually modified /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20231116152617.059/Casks/blackhole-2ch.rb at line 18-23 from

    system_command "/bin/launchctl",
                   args:         [
                     "kickstart",
                     "-kp",
                     "system/com.apple.audio.coreaudiod",
                   ],

to

    system_command "/usr/bin/killall",
                   args:         [
                     "coreaudiod",
                   ],

kyan001 avatar Apr 18 '24 02:04 kyan001

Thx @kyan001!

I had to modify it as the new recipe states (commit):

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

JavierCane avatar Apr 18 '24 08:04 JavierCane

I uninstalled the old version by manually modified /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20231116152617.059/Casks/blackhole-2ch.rb at line 18-23 from

    system_command "/bin/launchctl",
                   args:         [
                     "kickstart",
                     "-kp",
                     "system/com.apple.audio.coreaudiod",
                   ],

to

    system_command "/usr/bin/killall",
                   args:         [
                     "coreaudiod",
                   ],

Yep this fixed the brew upgrade command for me.

My file was located at /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20230911235106.162/Casks/blackhole-2ch.rb I assume this will be different for each system.

I recommend doing this in terminal:

  1. Open terminal
  2. Type: nano /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/
  3. Press tab until you see blackhole-2ch.rb filled out. Which will probably be different if you have the 4 channel

iambenmitchell avatar Apr 18 '24 22:04 iambenmitchell

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/blackhole-2ch/

Intel Mac rm -rfi /usr/local/Caskroom/blackhole-2ch/

Then reinstall brew reinstall blackhole-2ch

bevanjkay avatar Apr 19 '24 01:04 bevanjkay

I was running a second reinstall blackhole-64ch - and it was working. Thanks and have a nicce day

I followed bevanjkay -> it was working for blackhole-2ch and blackhole-16ch.

But not for: blackhole-64ch:

==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/1f1003545f569d4edd1605b305201d122feb66ed/Casks/b/blackhole-64ch.rb Already downloaded: /Users/bs/Library/Caches/Homebrew/downloads/6f266aa25cea5072a49537567e6d791240b75ee40f5a7b5672f2e987703bb2c8--blackhole-64ch.rb ==> Downloading https://existential.audio/downloads/BlackHole64ch-0.6.0.pkg Already downloaded: /Users/bs/Library/Caches/Homebrew/downloads/e3d9aac22defb66f385a873b85ae492aea540dc48984702df9c03837a8e525ea--BlackHole64ch-0.6.0.pkg ==> Installing Cask blackhole-64ch ==> Running installer for blackhole-64ch with sudo; the password may be necessary. installer: Package name is BlackHole: Audio Loopback Driver (64ch) 0.6.0 installer: Upgrading at base path / installer: The upgrade failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “BlackHole64ch-0.6.0.pkg”.) ==> Purging files for version 0.6.0 of Cask blackhole-64ch Error: Failure while executing; /usr/bin/sudo -u root -E LOGNAME=bs USER=bs USERNAME=bs -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/blackhole-64ch/0.6.0/BlackHole64ch-0.6.0.pkg -target / exited with 1. Here's the output: installer: Package name is BlackHole: Audio Loopback Driver (64ch) 0.6.0 installer: Upgrading at base path / installer: The upgrade failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “BlackHole64ch-0.6.0.pkg”.)

BrentSqAR avatar Apr 19 '24 12:04 BrentSqAR

For intel mac, /usr/local/Caskroom/blackhole-2ch/ instead of /opt/homebrew/Caskroom/blackhole-2ch/

Constantin1489 avatar Apr 20 '24 08:04 Constantin1489

Linking to the relevant issue on the BlackHole repo.

https://github.com/ExistentialAudio/BlackHole/issues/779

devinroth avatar Apr 22 '24 16:04 devinroth

BlackHole was transfered during the migration from my Intel Mac to the Silicon Mac. It worked after these commands:

rm -rf /usr/local/Caskroom/blackhole-2ch/ Then install again brew install blackhole-2ch

pattespatte avatar Apr 25 '24 19:04 pattespatte

I uninstalled the old version by manually modified /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20231116152617.059/Casks/blackhole-2ch.rb at line 18-23 from

    system_command "/bin/launchctl",
                   args:         [
                     "kickstart",
                     "-kp",
                     "system/com.apple.audio.coreaudiod",
                   ],

to

    system_command "/usr/bin/killall",
                   args:         [
                     "coreaudiod",
                   ],

bakcground-music had exactly the same issue, this file can be modified to fix it.

sudo nano /opt/homebrew/Caskroom/background-music/.metadata/0.4.0/20231225152717.155/Casks/background-music.rb

dobladov avatar Apr 29 '24 13:04 dobladov

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/blackhole-2ch/

Intel Mac rm -rfi /usr/local/Caskroom/blackhole-2ch/

Then reinstall brew reinstall blackhole-2ch

The worked for me if you dont include the "i" in rfi i.e.: rm -rf /opt/homebrew/Caskroom/blackhole-2ch/

Thanks all!

elvinos avatar May 02 '24 10:05 elvinos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar May 24 '24 00:05 github-actions[bot]

Has it been resolved? Or “won’t fix”?

Devin On May 23, 2024 at 5:05 PM -0700, github-actions[bot] @.***>, wrote:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

devinroth avatar May 24 '24 02:05 devinroth

The only way to globally resolve this would be to submit a PR to https://github.com/homebrew/Brew to detect and intercept the outdated kickstart command and replace it with the correct command. In future we would ideally replace these commands with a set of commands available through a Ruby DSL and not allow ad-hoc preflight/postflight blocks.

bevanjkay avatar May 24 '24 03:05 bevanjkay

The recommended command is retroactive if that makes any difference.

Devin On May 23, 2024 at 8:13 PM -0700, Bevan Kay @.***>, wrote:

The only way to globally resolve this would be to submit a PR to https://github.com/homebrew/Brew to detect and intercept the outdated kickstart command and replace it with the correct command. In future we would ideally replace these commands with a set of commands available through a Ruby DSL and not allow ad-hoc preflight/postflight blocks. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

devinroth avatar May 24 '24 07:05 devinroth

Closing this as workaround has been provided

krehel avatar Jul 05 '24 00:07 krehel

I tried all the above and its not working... (because my blackhole-2ch.rb doesn't exist) Then I figured out this workaround:

  1. Disable SIP (System Integrity Protection) : go to Recovery Mode and type the following in terminal csrutil disable

  2. Then go back to user: brew uninstall background-music

  3. Enable SIP again: go to Recovery Mode and type the following in terminal csrutil enable

dddanielliu avatar Jul 27 '24 10:07 dddanielliu

I uninstalled the old version by manually modified /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20231116152617.059/Casks/blackhole-2ch.rb at line 18-23 from

    system_command "/bin/launchctl",
                   args:         [
                     "kickstart",
                     "-kp",
                     "system/com.apple.audio.coreaudiod",
                   ],

to

    system_command "/usr/bin/killall",
                   args:         [
                     "coreaudiod",
                   ],

bakcground-music had exactly the same issue, this file can be modified to fix it.

sudo nano /opt/homebrew/Caskroom/background-music/.metadata/0.4.0/20231225152717.155/Casks/background-music.rb

Modifying background-music and then running brew uninstall background-music to invoke killall didn't work for me. Any advice @dobladov ?

â–¶ brew uninstall background-music
==> Uninstalling Cask background-music
==> Removing launchctl service com.bearisdriving.BGM.XPCHelper
Password:
==> 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
sudo: usr/bin/killall: command not found
Error: Failure while executing; `/usr/bin/sudo -E -- usr/bin/killall coreaudiod` exited with 1. Here's the output:
sudo: usr/bin/killall: command not found

BlkPingu avatar Jul 31 '24 09:07 BlkPingu

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/blackhole-2ch/

Intel Mac rm -rfi /usr/local/Caskroom/blackhole-2ch/

Then reinstall brew reinstall blackhole-2ch

finally! this one worked. thanks!

kazotaja avatar Aug 10 '24 15:08 kazotaja

instead of this fix i had issues with I did something else:

  1. Go into recovery mode (on M1 Mac shut it down, then start using the touch ID sensor, but hold it until you see "hold to boot into recovery mode" and release when you see "Booting into recovery mode", then log in your user, and open the terminal (utilities > terminal) from the menu bar

  2. disable system integrity protection (SIP): csrutil disable and reboot

  3. uninstall background music: brew uninstall background-music. it should work this time. and shut down the mac again completely

  4. enable SIP again, follow the above steps, when in SIP terminal: csrutil enable and reboot

profit

I uninstalled the old version by manually modified /opt/homebrew/Caskroom/blackhole-2ch/.metadata/0.5.0/20231116152617.059/Casks/blackhole-2ch.rb at line 18-23 from

    system_command "/bin/launchctl",
                   args:         [
                     "kickstart",
                     "-kp",
                     "system/com.apple.audio.coreaudiod",
                   ],

to

    system_command "/usr/bin/killall",
                   args:         [
                     "coreaudiod",
                   ],

bakcground-music had exactly the same issue, this file can be modified to fix it.

sudo nano /opt/homebrew/Caskroom/background-music/.metadata/0.4.0/20231225152717.155/Casks/background-music.rb

Modifying background-music and then running brew uninstall background-music to invoke killall didn't work for me. Any advice @dobladov ?

â–¶ brew uninstall background-music
==> Uninstalling Cask background-music
==> Removing launchctl service com.bearisdriving.BGM.XPCHelper
Password:
==> 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
sudo: usr/bin/killall: command not found
Error: Failure while executing; `/usr/bin/sudo -E -- usr/bin/killall coreaudiod` exited with 1. Here's the output:
sudo: usr/bin/killall: command not found

BlkPingu avatar Aug 26 '24 20:08 BlkPingu