cmd/upgrade: required named args when upgrading from source

The --build-from-source flag can currently be used without specifying
a formula by name but it doesn't behave the way you'd expect it to.

It will upgrade everything using bottles if they are available and skip
building things from source. This is intentional because we want to
discourage non-developers from building packages from source since the
result is less predictable.

The change here is to error out in that case. It might be smarter to
go through the entire deprecation cycle here just in case someone
is using this in scripts.
This commit is contained in:
apainintheneck 2024-10-14 20:49:04 -07:00
parent f957e0e9fa
commit 200452e23d

View File

@ -120,6 +120,10 @@ module Homebrew
sig { override.void }
def run
if args.build_from_source? && args.named.empty?
raise ArgumentError, "--build-from-source requires at least one formula"
end
formulae, casks = args.named.to_resolved_formulae_to_casks
# If one or more formulae are specified, but no casks were
# specified, we want to make note of that so we don't