diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index b83667fed6..66529cc027 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -28,6 +28,24 @@ module Homebrew tap = Tap.fetch(tapname) odie "Untapping #{tap} is not allowed" if tap.core_tap? + 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 + end + end + tap.uninstall end end