diff --git a/Library/Homebrew/cask/cask_loader.rb b/Library/Homebrew/cask/cask_loader.rb index 5116aadd9f..f2607b2e53 100644 --- a/Library/Homebrew/cask/cask_loader.rb +++ b/Library/Homebrew/cask/cask_loader.rb @@ -217,14 +217,17 @@ module Cask next unless loader_class.can_load?(ref) if loader_class == FromTapLoader && Homebrew::EnvConfig.install_from_api? && - ref.start_with?("homebrew/cask/") && !Tap.fetch("homebrew/cask").installed? && - Homebrew::API::CaskSource.available?(ref) + ref.start_with?("homebrew/cask/") && Homebrew::API::CaskSource.available?(ref) return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref)) end return loader_class.new(ref) end + if Homebrew::EnvConfig.install_from_api? && Homebrew::API::CaskSource.available?(ref) + return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref)) + end + return FromTapPathLoader.new(default_path(ref)) if FromTapPathLoader.can_load?(default_path(ref)) case (possible_tap_casks = tap_paths(ref)).count @@ -239,10 +242,6 @@ module Cask EOS end - if Homebrew::EnvConfig.install_from_api? && Homebrew::API::CaskSource.available?(ref) - return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref)) - end - possible_installed_cask = Cask.new(ref) return FromPathLoader.new(possible_installed_cask.installed_caskfile) if possible_installed_cask.installed? diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index cedb689d67..1aa705d0b1 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -149,7 +149,7 @@ module Homebrew updated_taps = [] Tap.each do |tap| next unless tap.git? - next if (tap.core_tap? || tap == "homebrew/cask") && Homebrew::EnvConfig.install_from_api? && args.auto_update? + next if (tap.core_tap? || tap == "homebrew/cask") && Homebrew::EnvConfig.install_from_api? if ENV["HOMEBREW_MIGRATE_LINUXBREW_FORMULAE"].present? && tap.core_tap? && Settings.read("linuxbrewmigrated") != "true" diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 19285aa4f8..f70fe6d09a 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -701,10 +701,7 @@ EOS for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/* do - # HOMEBREW_UPDATE_AUTO wasn't modified in subshell. - # shellcheck disable=SC2031 if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] && - [[ -n "${HOMEBREW_UPDATE_AUTO}" ]] && [[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]] then diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 1a8afb24a9..65858d3e43 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -641,7 +641,7 @@ module Formulary when URL_START_REGEX return FromUrlLoader.new(ref) when HOMEBREW_TAP_FORMULA_REGEX - if ref.start_with?("homebrew/core/") && !CoreTap.instance.installed? && Homebrew::EnvConfig.install_from_api? + if ref.start_with?("homebrew/core/") && Homebrew::EnvConfig.install_from_api? name = ref.split("/", 3).last return FormulaAPILoader.new(name) if Homebrew::API::Formula.all_formulae.key?(name) end @@ -651,18 +651,16 @@ module Formulary return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist? + if Homebrew::EnvConfig.install_from_api? && Homebrew::API::Formula.all_formulae.key?(ref) + return FormulaAPILoader.new(ref) + end + formula_with_that_name = core_path(ref) return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file? possible_alias = CoreTap.instance.alias_dir/ref return AliasLoader.new(possible_alias) if possible_alias.file? - if !CoreTap.instance.installed? && - Homebrew::EnvConfig.install_from_api? && - Homebrew::API::Formula.all_formulae.key?(ref) - return FormulaAPILoader.new(ref) - end - possible_tap_formulae = tap_paths(ref) raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1