From 6db19212c6ffbf1d561b8e26ac4e85484023e7c3 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 28 Oct 2021 17:13:34 -0400 Subject: [PATCH] Fix `brew untap` with `HOMEBREW_INSTALL_FROM_API` --- Library/Homebrew/cmd/untap.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index 3c51d60dfa..5245f4ad78 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -27,21 +27,23 @@ module Homebrew args.named.to_installed_taps.each do |tap| odie "Untapping #{tap} is not allowed" if tap.core_tap? && !Homebrew::EnvConfig.install_from_api? - installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap } - installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap } + if !Homebrew::EnvConfig.install_from_api? || (!tap.core_tap? && tap != "homebrew/cask") + installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap } + installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap } - if installed_tap_formulae.present? || installed_tap_casks.present? - installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n") - if args.force? || Homebrew::EnvConfig.developer? - opoo <<~EOS - Untapping #{tap} even though it contains the following installed formulae or casks: - #{installed_names} - EOS - else - odie <<~EOS - Refusing to untap #{tap} because it contains the following installed formulae or casks: - #{installed_names} - EOS + if installed_tap_formulae.present? || installed_tap_casks.present? + installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n") + if args.force? || Homebrew::EnvConfig.developer? + opoo <<~EOS + Untapping #{tap} even though it contains the following installed formulae or casks: + #{installed_names} + EOS + else + odie <<~EOS + Refusing to untap #{tap} because it contains the following installed formulae or casks: + #{installed_names} + EOS + end end end