HOMEBREW_INSTALL_FROM_API: various improvements.

- flip the messaging to refer to `HOMEBREW_NO_INSTALL_FROM_API` where relevant
- remove some duplicate checks
- better scope checks to just core tap formulae
This commit is contained in:
Mike McQuaid 2023-01-24 16:26:31 +00:00
parent 8f419180cf
commit 46d727b475
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
5 changed files with 20 additions and 12 deletions

View File

@ -91,8 +91,15 @@ begin
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd) if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
if Commands::INSTALL_FROM_API_FORBIDDEN_COMMANDS.include?(cmd) && if Commands::INSTALL_FROM_API_FORBIDDEN_COMMANDS.include?(cmd) &&
!CoreTap.instance.installed? &&
Homebrew::EnvConfig.install_from_api? && !Homebrew::EnvConfig.developer? Homebrew::EnvConfig.install_from_api? && !Homebrew::EnvConfig.developer?
odie "This command cannot be run while HOMEBREW_INSTALL_FROM_API is set!" odie <<~EOS
This command cannot be run while Homebrew/homebrew-core is untapped and
HOMEBREW_NO_INSTALL_FROM_API is unset! To resolve please run:
brew tap Homebrew/core
export HOMEBREW_NO_INSTALL_FROM_API=1
and retry this command.
EOS
end end
Homebrew.send Commands.method_name(cmd) Homebrew.send Commands.method_name(cmd)

View File

@ -146,10 +146,6 @@ module Homebrew
def install def install
args = install_args.parse args = install_args.parse
if args.build_from_source? && Homebrew::EnvConfig.install_from_api?
raise UsageError, "--build-from-source is not supported when using HOMEBREW_INSTALL_FROM_API."
end
if args.env.present? if args.env.present?
# Can't use `replacement: false` because `install_args` are used by # Can't use `replacement: false` because `install_args` are used by
# `build.rb`. Instead, `hide_from_man_page` and don't do anything with # `build.rb`. Instead, `hide_from_man_page` and don't do anything with

View File

@ -94,10 +94,6 @@ module Homebrew
def reinstall def reinstall
args = reinstall_args.parse args = reinstall_args.parse
if args.build_from_source? && Homebrew::EnvConfig.install_from_api?
raise UsageError, "--build-from-source is not supported when using HOMEBREW_INSTALL_FROM_API."
end
formulae, casks = args.named.to_formulae_and_casks(method: :resolve) formulae, casks = args.named.to_formulae_and_casks(method: :resolve)
.partition { |o| o.is_a?(Formula) } .partition { |o| o.is_a?(Formula) }

View File

@ -64,7 +64,10 @@ module Homebrew
message = if Homebrew::EnvConfig.install_from_api? message = if Homebrew::EnvConfig.install_from_api?
<<~EOS <<~EOS
#{not_exist_message} #{not_exist_message}
This is expected with HOMEBREW_INSTALL_FROM_API set! This is expected with HOMEBREW_NO_INSTALL_FROM_API unset! To resolve please run:
brew tap Homebrew/core
export HOMEBREW_NO_INSTALL_FROM_API=1
and retry this command.
EOS EOS
elsif args.cask? elsif args.cask?
<<~EOS <<~EOS

View File

@ -1181,8 +1181,14 @@ class FormulaInstaller
if pour_bottle?(output_warning: true) if pour_bottle?(output_warning: true)
formula.fetch_bottle_tab formula.fetch_bottle_tab
elsif formula.core_formula? && Homebrew::EnvConfig.install_from_api? elsif formula.core_formula? && !formula.tap.installed? && Homebrew::EnvConfig.install_from_api?
odie "Unable to build #{formula.name} from source with HOMEBREW_INSTALL_FROM_API." odie <<~EOS
Unable to build #{formula.name} from source while Homebrew/homebrew-core is
untapped and HOMEBREW_NO_INSTALL_FROM_API is unset! To resolve please run:
brew tap Homebrew/core
export HOMEBREW_NO_INSTALL_FROM_API=1
and retry.
EOS
else else
formula.fetch_patches formula.fetch_patches
formula.resources.each(&:fetch) formula.resources.each(&:fetch)