From ac53a6ae361fb4ddc38470dcbaea2d36c2f1b00d Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Tue, 19 Jul 2022 18:06:42 -0400 Subject: [PATCH 1/3] Instruct user to tap untapped official tap when running its commands This came up in https://github.com/Homebrew/homebrew-bundle/issues/1108 wherein a user had unwittingly untapped some official taps that get automatically tapped on first use and couldn't figure out why they couldn't use the associated command. --- Library/Homebrew/brew.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index b514d00621..42911fa9a4 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -104,6 +104,13 @@ begin possible_tap = Tap.fetch(possible_tap.first) if possible_tap if !possible_tap || possible_tap.installed? || Tap.untapped_official_taps.include?(possible_tap.name) + blocked_tap = possible_tap && Tap.untapped_official_taps.include?(possible_tap.name) + if blocked_tap + [ + "`brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped and cannot be retapped.", + "Run `brew tap #{possible_tap.name}` to reenable `brew #{cmd}`.", + ].each { |ln| onoe ln } + end # Check for cask explicitly because it's very common in old guides odie "`brew cask` is no longer a `brew` command. Use `brew --cask` instead." if cmd == "cask" odie "Unknown command: #{cmd}" From 5e56b9effe62b9d78b831d3dd3dff680fd97bb2b Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Thu, 21 Jul 2022 11:51:21 -0400 Subject: [PATCH 2/3] Drops "cannot be retapped" from manual untap warning Co-authored-by: Mike McQuaid --- Library/Homebrew/brew.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 42911fa9a4..cfb09f5353 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -107,7 +107,7 @@ begin blocked_tap = possible_tap && Tap.untapped_official_taps.include?(possible_tap.name) if blocked_tap [ - "`brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped and cannot be retapped.", + "`brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped.", "Run `brew tap #{possible_tap.name}` to reenable `brew #{cmd}`.", ].each { |ln| onoe ln } end From e7052fad0d970f1641dbd11a892fe9676832d08f Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Thu, 21 Jul 2022 13:19:54 -0400 Subject: [PATCH 3/3] Use heredoc for multiline error and store untapped official taps check Review feedback on https://github.com/Homebrew/brew/pull/13581#pullrequestreview-1046232447 --- Library/Homebrew/brew.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index cfb09f5353..7f52b5a483 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -103,13 +103,14 @@ begin possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } possible_tap = Tap.fetch(possible_tap.first) if possible_tap - if !possible_tap || possible_tap.installed? || Tap.untapped_official_taps.include?(possible_tap.name) - blocked_tap = possible_tap && Tap.untapped_official_taps.include?(possible_tap.name) + if !possible_tap || + possible_tap.installed? || + (blocked_tap = Tap.untapped_official_taps.include?(possible_tap.name)) if blocked_tap - [ - "`brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped.", - "Run `brew tap #{possible_tap.name}` to reenable `brew #{cmd}`.", - ].each { |ln| onoe ln } + onoe <<~EOS + `brew #{cmd}` is unavailable because #{possible_tap.name} was manually untapped. + Run `brew tap #{possible_tap.name}` to reenable `brew #{cmd}`. + EOS end # Check for cask explicitly because it's very common in old guides odie "`brew cask` is no longer a `brew` command. Use `brew --cask` instead." if cmd == "cask"