Mac 用 BlackHole が Apple Silicon 移行後にアンインストールできない問題を解決

Intel CPU 時代ゲームとマイクなどの複数のソースの音声を OBS で録音することができず、ボクはbrewBlackHole というオーディオループバックドライバをインストールしていました。その後 M1 Mac Mini を購入し Time Machine のバックアップから移行アシスタントを使用して環境を持ってきたのですが、どうやらこれが原因でbrewによる BlackHole のアンインストールができなくなっていたみたいです。もしくはどこかで適当に調べて実行した削除方法が悪手だったのかもしれません。ともあれ、解決方法が見つかったので共有します。インストール済みのチャネル数に応じて、2ch であればblackhole-2chと読み替えて (コマンド等は書き換えて) ください。あ、ちなみに OBS は複数ソースの取り込みに対応しているので、BlackHole は不要になりました。

症状

brew upgradeを実行するたびについでに実行されていたblackhole-16chのアンインストールが、以下のエラーで失敗していました。brew uninstall -f blackhole-16chとやっても同様です。

==> Uninstalling Cask blackhole-16ch
==> Uninstalling packages with sudo; the password may be necessary:
Password:
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

どうやったかは覚えていないのですが、すでに BlackHole-16ch の実体は削除済みだったので Audio MIDI 設定.app にも表示されず目に見える実害はありませんでした。ただbrew ugrade後に自動で走るbrew cleanupが長いこと実行されていなかったので、多少無駄なディスク容量は使用していたことになります。

解決方法

チャネル数やバージョン、ビルドされた日付などによって細かいところは違うと思いますが、おおよそ以下のフォーマットに近いフォルダにblackhole-*ch.rbというファイルがあるはずなので見つけてください。

/opt/homebrew/Caskroom/blackhole-16ch/.metadata/0.5.0/20230225072426.180/Casks/blackhole-16ch.rb

そのファイルの中に以下の記載があるので、エディタで編集して保存します。

編集前:

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

編集後:

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

その後アンインストールすると、エラーも無く完了します。以下は実行例です。

% brew uninstall blackhole-16ch
==> Uninstalling Cask blackhole-16ch
==> Uninstalling packages with sudo; the password may be necessary:
Password:
==> Purging files for version 0.5.0 of Cask blackhole-16ch
==> Autoremoving 1 unneeded formula:
libgit2
Uninstalling /opt/homebrew/Cellar/libgit2/1.9.0... (109 files, 4.9MB)

ボクはこの後brew upgradeを実行したところ自動でbrew cleanupが走り、BlackHole-16ch もキレイに削除されたのがわかりました。

% brew update
==> Updating Homebrew...
Already up-to-date.
% brew upgrade
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
...
Removing: /opt/homebrew/cache/api-source/Homebrew/homebrew-cask/2aaef0803d773e0427dea5899e5830877ff0e7d4/Cask/blackhole-16ch.rb... (924B)
Removing: /opt/homebrew/cache/api-source/Homebrew/homebrew-cask/33834b5bb4afa8aeee187913c3aa915a26da6230/Cask/blackhole-16ch.rb... (924B)
Removing: /opt/homebrew/cache/api-source/Homebrew/homebrew-cask/58c8ced139c9482c318bb6bd3bc844d54c69c164/Cask/blackhole-16ch.rb... (924B)
...

以上で完了です。

参考にしたページ

参考にした下記の GitHub Discussion では、バージョン 0.5.0 を 0.6.0 にアップグレードできないという件について書かれています。

https://github.com/ExistentialAudio/BlackHole/discussions/781

解決できてスッキリ

ブラックホールだけに抜け出せないかと思いました。やかましいですね。

Image by Stable Diffusion (Mochi Diffusion)

そのまんま「ブラックホールからの脱出」をテーマに描いてもらいました。割とうまくいかず、自分もどう細かい指示をして良いのかわからず、ただただ大量に生成して、まぁなんとか「ブラックホールから脱出した宇宙飛行士の自撮り」ができました。

Date:
2025年1月20日 0:45:54

Model:
realisticVision-v51VAE_original_768x512_cn

Size:
768 x 512

Include in Image:
selfie of an astronaut who just escaped from a blackhole

Exclude from Image:

Seed:
1463892356

Steps:
20

Guidance Scale:
20.0

Scheduler:
DPM-Solver++

ML Compute Unit:
CPU & GPU

“Mac 用 BlackHole が Apple Silicon 移行後にアンインストールできない問題を解決” への1件の返信

  1. 編集したけどこうなりました。
    % brew uninstall blackhole-16ch
    ==> Uninstalling Cask blackhole-16ch
    ==> Quitting application ‘com.apple.audio.AudioMIDISetup’…
    Application ‘com.apple.audio.AudioMIDISetup’ quit successfully.
    ==> Uninstalling packages with sudo; the password may be necessary:
    Password:
    No matching processes were found
    Error: Failure while executing; `/usr/bin/sudo -E — /usr/bin/killall coreaudio` exited with 1. Here’s the output:
    No matching processes were found

    % ps aux|grep coreaudio
    _coreaudiod 238 0.0 0.0 426916640 1936 ?? S 2 625 1:21.87 /usr/sbin/distnoted agent
    _coreaudiod 203 0.0 0.0 426981216 7056 ?? Ss 2 625 408:54.87 /usr/sbin/coreaudiod
    handsome 97026 0.0 0.0 410060096 32 s000 S+ 8:54AM 0:00.00 grep coreaudio

    んで、なんとなく編集内容を元に戻し、再度削除を試したところイケました。
    % vi blackhole-16ch.rb
    (ここで元に戻す)
    % sudo killall coreaudio
    No matching processes were found
    % brew uninstall -f blackhole-16ch
    ==> Uninstalling Cask blackhole-16ch
    ==> Purging files for version 0.5.0 of Cask blackhole-16ch
    ==> Autoremoving 14 unneeded formulae:
    abseil
    ghostscript
    hwloc
    jbig2dec
    [email protected]
    libidn
    libpthread-stubs
    onnx
    openvino
    pcre
    protobuf
    pugixml
    six
    tbb
    Uninstalling /opt/homebrew/Cellar/ghostscript/10.05.1… (640 files, 122.2MB)
    Uninstalling /opt/homebrew/Cellar/openvino/2025.0.0… (779 files, 111.0MB)
    Uninstalling /opt/homebrew/Cellar/libpthread-stubs/0.5… (5 files, 6.8KB)
    Uninstalling /opt/homebrew/Cellar/pcre/8.45… (204 files, 4.7MB)
    Uninstalling /opt/homebrew/Cellar/six/1.17.0… (20 files, 90.8KB)
    Uninstalling /opt/homebrew/Cellar/[email protected]/1.7.2… (105 files, 4.5MB)
    Uninstalling /opt/homebrew/Cellar/onnx/1.17.0_2… (105 files, 5.4MB)
    Uninstalling /opt/homebrew/Cellar/tbb/2022.2.0… (180 files, 2.8MB)
    Uninstalling /opt/homebrew/Cellar/jbig2dec/0.20… (13 files, 422.7KB)
    Uninstalling /opt/homebrew/Cellar/libidn/1.43… (74 files, 1MB)
    Uninstalling /opt/homebrew/Cellar/pugixml/1.15… (16 files, 504.9KB)
    Uninstalling /opt/homebrew/Cellar/hwloc/2.12.1… (976 files, 10.8MB)
    Uninstalling /opt/homebrew/Cellar/protobuf/29.3… (445 files, 15.3MB)
    Uninstalling /opt/homebrew/Cellar/abseil/20240722.1… (772 files, 11.8MB)
    [arm] mac-mini:/opt/homebrew/Caskroom/blackhole-16ch/.metadata/0.5.0/20230225072426.180/Casks%
    [arm] mac-mini:/opt/homebrew/Caskroom/blackhole-16ch/.metadata/0.5.0/20230225072426.180/Casks%
    [arm] mac-mini:/opt/homebrew/Caskroom/blackhole-16ch/.metadata/0.5.0/20230225072426.180/Casks% brew update
    shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
    Error: The current working directory must exist to run brew.
    [arm] mac-mini:/opt/homebrew/Caskroom/blackhole-16ch/.metadata/0.5.0/20230225072426.180/Casks% cd
    [arm] mac-mini:~% brew update
    ==> Updating Homebrew…
    Already up-to-date.

    % brew upgrade
    (アップグレードが走ったのち…)
    ==> `brew cleanup` has not been run in the last 30 days, running now…
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
    (諸々不要なパッケージを削除してくれた)

    % brew list blackhole-16ch
    Error: Cask ‘blackhole-16ch’ is not installed.
    % brew search blackhole-16ch
    ==> Casks
    blackhole-16ch blackhole-2ch blackhole-64ch

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

© Peddals.com