Merge pull request #20479 from Homebrew/inline-docs-updates

Messaging and comment adjustments
This commit is contained in:
Eric Knibbe 2025-08-16 13:04:38 +00:00 committed by GitHub
commit 884a3ae468
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 122 additions and 118 deletions

View File

@ -27,7 +27,7 @@ module Homebrew
api_url = "#{HOMEBREW_API_DEFAULT_DOMAIN}/#{endpoint}" api_url = "#{HOMEBREW_API_DEFAULT_DOMAIN}/#{endpoint}"
output = Utils::Curl.curl_output("--fail", api_url) output = Utils::Curl.curl_output("--fail", api_url)
end end
raise ArgumentError, "No file found at #{Tty.underline}#{api_url}#{Tty.reset}" unless output.success? raise ArgumentError, "No file found at: #{Tty.underline}#{api_url}#{Tty.reset}" unless output.success?
cache[endpoint] = JSON.parse(output.stdout, freeze: true) cache[endpoint] = JSON.parse(output.stdout, freeze: true)
rescue JSON::ParserError rescue JSON::ParserError

View File

@ -713,8 +713,8 @@ else
then then
message="Please update your system curl or set HOMEBREW_CURL_PATH to a newer version. message="Please update your system curl or set HOMEBREW_CURL_PATH to a newer version.
Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION} Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION}
Your curl version: ${curl_name_and_version##* } Your curl version: ${curl_name_and_version##* }
Your curl executable: $(type -p "${HOMEBREW_CURL}")" Your curl executable: $(type -p "${HOMEBREW_CURL}")"
if [[ -z ${HOMEBREW_CURL_PATH} ]] if [[ -z ${HOMEBREW_CURL_PATH} ]]
then then
@ -741,8 +741,8 @@ Your curl executable: $(type -p "${HOMEBREW_CURL}")"
then then
message="Please update your system Git or set HOMEBREW_GIT_PATH to a newer version. message="Please update your system Git or set HOMEBREW_GIT_PATH to a newer version.
Minimum required version: ${HOMEBREW_MINIMUM_GIT_VERSION} Minimum required version: ${HOMEBREW_MINIMUM_GIT_VERSION}
Your Git version: ${major}.${minor}.${micro}.${build} Your Git version: ${major}.${minor}.${micro}.${build}
Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")" Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")"
if [[ -z ${HOMEBREW_GIT_PATH} ]] if [[ -z ${HOMEBREW_GIT_PATH} ]]
then then
HOMEBREW_FORCE_BREWED_GIT="1" HOMEBREW_FORCE_BREWED_GIT="1"

View File

@ -389,7 +389,7 @@ module Cask
end end
def uninstall_pkgutil(*pkgs, command: nil, **_) def uninstall_pkgutil(*pkgs, command: nil, **_)
ohai "Uninstalling packages with sudo; the password may be necessary:" ohai "Uninstalling packages with `sudo` (which may request your password)..."
pkgs.each do |regex| pkgs.each do |regex|
::Cask::Pkg.all_matching(regex, command).each do |pkg| ::Cask::Pkg.all_matching(regex, command).each do |pkg|
puts pkg.package_id puts pkg.package_id

View File

@ -35,7 +35,7 @@ module Cask
private private
def run_installer(command: nil, verbose: false, **_options) def run_installer(command: nil, verbose: false, **_options)
ohai "Running installer for #{cask} with sudo; the password may be necessary." ohai "Running installer for #{cask} with `sudo` (which may request your password)..."
unless path.exist? unless path.exist?
pkg = path.relative_path_from(cask.staged_path) pkg = path.relative_path_from(cask.staged_path)
pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) } pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) }

View File

@ -25,7 +25,7 @@ module Cask
full_paths = remove_nonexistent(paths) full_paths = remove_nonexistent(paths)
return if full_paths.empty? return if full_paths.empty?
ohai "Changing ownership of paths required by #{@cask} with sudo; the password may be necessary." ohai "Changing ownership of paths required by #{@cask} with `sudo` (which may request your password)..."
@command.run!("/usr/sbin/chown", args: ["-R", "--", "#{user}:#{group}", *full_paths], @command.run!("/usr/sbin/chown", args: ["-R", "--", "#{user}:#{group}", *full_paths],
sudo: true) sudo: true)
end end

View File

@ -88,8 +88,8 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
raise UsageError, "`brew deps --os=all` is not supported" if args.os == "all" raise UsageError, "`brew deps --os=all` is not supported." if args.os == "all"
raise UsageError, "`brew deps --arch=all` is not supported" if args.arch == "all" raise UsageError, "`brew deps --arch=all` is not supported." if args.arch == "all"
os, arch = T.must(args.os_arch_combinations.first) os, arch = T.must(args.os_arch_combinations.first)
eval_all = args.eval_all? eval_all = args.eval_all?

View File

@ -181,7 +181,7 @@ module Homebrew
# `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
# this argument here. # this argument here.
# This odisabled should stick around indefinitely. # This odisabled should stick around indefinitely.
odisabled "brew install --env", "`env :std` in specific formula files" odisabled "`brew install --env`", "`env :std` in specific formula files"
end end
args.named.each do |name| args.named.each do |name|

View File

@ -25,27 +25,27 @@ module Homebrew
If `sudo` is passed, operate on `/Library/LaunchDaemons` or `/usr/lib/systemd/system` (started at boot). If `sudo` is passed, operate on `/Library/LaunchDaemons` or `/usr/lib/systemd/system` (started at boot).
Otherwise, operate on `~/Library/LaunchAgents` or `~/.config/systemd/user` (started at login). Otherwise, operate on `~/Library/LaunchAgents` or `~/.config/systemd/user` (started at login).
[`sudo`] `brew services` [`list`] (`--json`) (`--debug`): [`sudo`] `brew services` [`list`] [`--json`] [`--debug`]:
List information about all managed services for the current user (or root). List information about all managed services for the current user (or root).
Provides more output from Homebrew and `launchctl`(1) or `systemctl`(1) if run with `--debug`. Provides more output from Homebrew and `launchctl`(1) or `systemctl`(1) if run with `--debug`.
[`sudo`] `brew services info` (<formula>|`--all`|`--json`): [`sudo`] `brew services info` (<formula>|`--all`) [`--json`]:
List all managed services for the current user (or root). List all managed services for the current user (or root).
[`sudo`] `brew services run` (<formula>|`--all`|`--file=`): [`sudo`] `brew services run` (<formula>|`--all`) [`--file=`]:
Run the service <formula> without registering to launch at login (or boot). Run the service <formula> without registering to launch at login (or boot).
[`sudo`] `brew services start` (<formula>|`--all`|`--file=`): [`sudo`] `brew services start` (<formula>|`--all`) [`--file=`]:
Start the service <formula> immediately and register it to launch at login (or boot). Start the service <formula> immediately and register it to launch at login (or boot).
[`sudo`] `brew services stop` (`--keep`) (`--no-wait`|`--max-wait=`) (<formula>|`--all`): [`sudo`] `brew services stop` [`--keep`] [`--no-wait`|`--max-wait=`] (<formula>|`--all`):
Stop the service <formula> immediately and unregister it from launching at login (or boot), Stop the service <formula> immediately and unregister it from launching at login (or boot),
unless `--keep` is specified. unless `--keep` is specified.
[`sudo`] `brew services kill` (<formula>|`--all`): [`sudo`] `brew services kill` (<formula>|`--all`):
Stop the service <formula> immediately but keep it registered to launch at login (or boot). Stop the service <formula> immediately but keep it registered to launch at login (or boot).
[`sudo`] `brew services restart` (<formula>|`--all`|`--file=`): [`sudo`] `brew services restart` (<formula>|`--all`) [`--file=`]:
Stop (if necessary) and start the service <formula> immediately and register it to launch at login (or boot). Stop (if necessary) and start the service <formula> immediately and register it to launch at login (or boot).
[`sudo`] `brew services cleanup`: [`sudo`] `brew services cleanup`:
@ -58,15 +58,16 @@ module Homebrew
flag "--max-wait=", flag "--max-wait=",
description: "Wait at most this many seconds for `stop` to finish stopping a service. " \ description: "Wait at most this many seconds for `stop` to finish stopping a service. " \
"Defaults to 60. Set this to zero (0) seconds to wait indefinitely." "Defaults to 60. Set this to zero (0) seconds to wait indefinitely."
switch "--all",
description: "Run <subcommand> on all services."
switch "--json",
description: "Output as JSON."
switch "--no-wait", switch "--no-wait",
description: "Don't wait for `stop` to finish stopping the service." description: "Don't wait for `stop` to finish stopping the service."
switch "--keep", switch "--keep",
description: "When stopped, don't unregister the service from launching at login (or boot)." description: "When stopped, don't unregister the service from launching at login (or boot)."
switch "--all",
description: "Run <subcommand> on all services."
switch "--json",
description: "Output as JSON."
conflicts "--all", "--file"
conflicts "--max-wait=", "--no-wait" conflicts "--max-wait=", "--no-wait"
named_args %w[list info run start stop kill restart cleanup] named_args %w[list info run start stop kill restart cleanup]
@ -112,7 +113,7 @@ module Homebrew
] ]
if no_named_formula_commands.include?(subcommand) if no_named_formula_commands.include?(subcommand)
raise UsageError, "The `#{subcommand}` subcommand does not accept a formula argument!" if formulae.present? raise UsageError, "The `#{subcommand}` subcommand does not accept a formula argument!" if formulae.present?
raise UsageError, "The `#{subcommand}` subcommand does not accept the --all argument!" if args.all? raise UsageError, "The `#{subcommand}` subcommand does not accept the `--all` argument!" if args.all?
end end
if args.file if args.file
@ -122,22 +123,22 @@ module Homebrew
*Homebrew::Services::Commands::Restart::TRIGGERS, *Homebrew::Services::Commands::Restart::TRIGGERS,
] ]
if file_commands.exclude?(subcommand) if file_commands.exclude?(subcommand)
raise UsageError, "The `#{subcommand}` subcommand does not accept the --file= argument!" raise UsageError, "The `#{subcommand}` subcommand does not accept the `--file=` argument!"
elsif args.all?
raise UsageError,
"The `#{subcommand}` subcommand does not accept the --all and --file= arguments at the same time!"
end end
end end
unless Homebrew::Services::Commands::Stop::TRIGGERS.include?(subcommand) unless Homebrew::Services::Commands::Stop::TRIGGERS.include?(subcommand)
raise UsageError, "The `#{subcommand}` subcommand does not accept the --keep argument!" if args.keep? raise UsageError, "The `#{subcommand}` subcommand does not accept the `--keep` argument!" if args.keep?
raise UsageError, "The `#{subcommand}` subcommand does not accept the --no-wait argument!" if args.no_wait?
if args.no_wait?
raise UsageError, "The `#{subcommand}` subcommand does not accept the `--no-wait` argument!"
end
if args.max_wait if args.max_wait
raise UsageError, "The `#{subcommand}` subcommand does not accept the --max-wait= argument!" raise UsageError, "The `#{subcommand}` subcommand does not accept the `--max-wait=` argument!"
end end
end end
opoo "The --all argument overrides provided formula argument!" if formulae.present? && args.all? opoo "The `--all` argument overrides provided formula argument!" if formulae.present? && args.all?
targets = if args.all? targets = if args.all?
if subcommand == "start" if subcommand == "start"

View File

@ -126,7 +126,7 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
if args.build_from_source? && args.named.empty? if args.build_from_source? && args.named.empty?
raise ArgumentError, "--build-from-source requires at least one formula" raise ArgumentError, "`--build-from-source` requires at least one formula"
end end
formulae, casks = args.named.to_resolved_formulae_to_casks formulae, casks = args.named.to_resolved_formulae_to_casks

View File

@ -40,7 +40,7 @@ class CompilerFailure
# Non-Apple compilers are in the format fails_with compiler => version # Non-Apple compilers are in the format fails_with compiler => version
if spec.is_a?(Hash) if spec.is_a?(Hash)
compiler, major_version = spec.first compiler, major_version = spec.first
raise ArgumentError, "The hash `fails_with` syntax only supports GCC" if compiler != :gcc raise ArgumentError, "The `fails_with` hash syntax only supports GCC" if compiler != :gcc
type = compiler type = compiler
# so fails_with :gcc => '7' simply marks all 7 releases incompatible # so fails_with :gcc => '7' simply marks all 7 releases incompatible

View File

@ -3,7 +3,7 @@
# #
# - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections): # - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections):
# - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`. # - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`.
# - For `.rb` files, edit the `<command>_args` method. # - For `.rb` files, edit the `cmd_args` block.
# - For `.sh` files, edit the top comment, being sure to use the line prefix # - For `.sh` files, edit the top comment, being sure to use the line prefix
# `#:` for the comments to be recognized as documentation. If in doubt, # `#:` for the comments to be recognized as documentation. If in doubt,
# compare with already documented commands. # compare with already documented commands.

View File

@ -3,7 +3,7 @@
# #
# - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections): # - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections):
# - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`. # - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`.
# - For `.rb` files, edit the `<command>_args` method. # - For `.rb` files, edit the `cmd_args` block.
# - For `.sh` files, edit the top comment, being sure to use the line prefix # - For `.sh` files, edit the top comment, being sure to use the line prefix
# `#:` for the comments to be recognized as documentation. If in doubt, # `#:` for the comments to be recognized as documentation. If in doubt,
# compare with already documented commands. # compare with already documented commands.

View File

@ -3,7 +3,7 @@
# #
# - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections): # - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections):
# - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`. # - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`.
# - For `.rb` files, edit the `<command>_args` method. # - For `.rb` files, edit the `cmd_args` block.
# - For `.sh` files, edit the top comment, being sure to use the line prefix # - For `.sh` files, edit the top comment, being sure to use the line prefix
# `#:` for the comments to be recognized as documentation. If in doubt, # `#:` for the comments to be recognized as documentation. If in doubt,
# compare with already documented commands. # compare with already documented commands.

View File

@ -169,7 +169,7 @@ class DependencyCollector
when :maximum_macos then MacOSRequirement.new(tags, comparator: "<=") when :maximum_macos then MacOSRequirement.new(tags, comparator: "<=")
when :xcode then XcodeRequirement.new(tags) when :xcode then XcodeRequirement.new(tags)
else else
raise ArgumentError, "Unsupported special dependency #{spec.inspect}" raise ArgumentError, "Unsupported special dependency: #{spec.inspect}"
end end
end end

View File

@ -104,7 +104,7 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
odeprecated "brew audit --token-conflicts" if args.token_conflicts? odeprecated "`brew audit --token-conflicts`" if args.token_conflicts?
Formulary.enable_factory_cache! Formulary.enable_factory_cache!
@ -142,7 +142,7 @@ module Homebrew
unless eval_all unless eval_all
# This odisabled should probably stick around indefinitely. # This odisabled should probably stick around indefinitely.
odisabled "brew audit", odisabled "`brew audit`",
"`brew audit --eval-all` or set `HOMEBREW_EVAL_ALL=1`" "`brew audit --eval-all` or set `HOMEBREW_EVAL_ALL=1`"
end end
no_named_args = true no_named_args = true
@ -154,8 +154,8 @@ module Homebrew
if args.named.any? { |named_arg| named_arg.end_with?(".rb") } if args.named.any? { |named_arg| named_arg.end_with?(".rb") }
# This odisabled should probably stick around indefinitely, # This odisabled should probably stick around indefinitely,
# until at least we have a way to exclude error on these in the CLI parser. # until at least we have a way to exclude error on these in the CLI parser.
odisabled "brew audit [path ...]", odisabled "`brew audit [path ...]`",
"brew audit [name ...]" "`brew audit [name ...]`"
end end
args.named.to_formulae_and_casks_with_taps args.named.to_formulae_and_casks_with_taps

View File

@ -57,15 +57,15 @@ module Homebrew
syntax_only = args.syntax_only? syntax_only = args.syntax_only?
repository = ENV.fetch("GITHUB_REPOSITORY", nil) repository = ENV.fetch("GITHUB_REPOSITORY", nil)
raise UsageError, "The GITHUB_REPOSITORY environment variable must be set." if repository.blank? raise UsageError, "The `$GITHUB_REPOSITORY` environment variable must be set." if repository.blank?
tap = T.let(Tap.fetch(repository), Tap) tap = T.let(Tap.fetch(repository), Tap)
unless syntax_only unless syntax_only
raise UsageError, "Either `--cask` or `--url` must be specified." if !args.casks? && !args.url? raise UsageError, "Either `--cask` or `--url` must be specified." if !args.casks? && !args.url?
raise UsageError, "Please provide a cask or url argument" if casks.blank? && pr_url.blank? raise UsageError, "Please provide a `--cask` or `--url` argument." if casks.blank? && pr_url.blank?
end end
raise UsageError, "Only one url can be specified" if pr_url&.count&.> 1 raise UsageError, "Only one `--url` can be specified." if pr_url&.count&.> 1
labels = if pr_url && (first_pr_url = pr_url.first) labels = if pr_url && (first_pr_url = pr_url.first)
pr = GitHub::API.open_rest(first_pr_url) pr = GitHub::API.open_rest(first_pr_url)

View File

@ -1600,7 +1600,7 @@ class DownloadStrategyDetector
detect_from_symbol(using) detect_from_symbol(using)
else else
raise TypeError, raise TypeError,
"Unknown download strategy specification #{using.inspect}" "Unknown download strategy specification: #{using.inspect}"
end end
end end

View File

@ -267,7 +267,7 @@ module SharedEnvExtension
ohai "Using a Fortran compiler found at #{gfortran}" ohai "Using a Fortran compiler found at #{gfortran}"
end end
if gfortran if gfortran
puts "This may be changed by setting the FC environment variable." puts "This may be changed by setting the `$FC` environment variable."
self["FC"] = self["F77"] = gfortran self["FC"] = self["F77"] = gfortran
flags = FC_FLAG_VARS flags = FC_FLAG_VARS
end end

View File

@ -417,7 +417,7 @@ module OS
macOS won't move relative symlinks across volumes unless the target file already macOS won't move relative symlinks across volumes unless the target file already
exists. Formulae known to be affected by this are Git and Narwhal. exists. Formulae known to be affected by this are Git and Narwhal.
You should set the "HOMEBREW_TEMP" environment variable to a suitable You should set the `$HOMEBREW_TEMP` environment variable to a suitable
directory on the same volume as your Cellar. directory on the same volume as your Cellar.
#{support_tier_message(tier: 2)} #{support_tier_message(tier: 2)}

View File

@ -791,7 +791,7 @@ module Homebrew
formula_suffix = stable.version.patch.to_i formula_suffix = stable.version.patch.to_i
throttled_rate = formula.livecheck.throttle throttled_rate = formula.livecheck.throttle
if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero?
problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" problem "Should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}"
end end
case (url = stable.url) case (url = stable.url)

View File

@ -382,7 +382,7 @@ class FormulaInstaller
check_installation_already_attempted check_installation_already_attempted
if force_bottle? && !pour_bottle? if force_bottle? && !pour_bottle?
raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!" raise CannotInstallFormulaError, "`--force-bottle` passed but #{formula.full_name} has no bottle!"
end end
if Homebrew.default_prefix? && if Homebrew.default_prefix? &&
@ -477,7 +477,7 @@ class FormulaInstaller
raise CannotInstallFormulaError, raise CannotInstallFormulaError,
"You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing " \ "You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing " \
"#{formula.full_name} requires the latest version of pinned dependencies" "#{formula.full_name} requires the latest version of pinned dependencies."
end end
sig { params(_formula: Formula).returns(T.nilable(T::Boolean)) } sig { params(_formula: Formula).returns(T.nilable(T::Boolean)) }

View File

@ -711,7 +711,7 @@ module Formulary
if ALLOWED_URL_SCHEMES.exclude?(url_scheme) if ALLOWED_URL_SCHEMES.exclude?(url_scheme)
raise UnsupportedInstallationMethod, raise UnsupportedInstallationMethod,
"Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! " \ "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! " \
"`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap " \ "Use `brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap " \
"on GitHub instead." "on GitHub instead."
end end
HOMEBREW_CACHE_FORMULA.mkpath HOMEBREW_CACHE_FORMULA.mkpath

View File

@ -83,10 +83,10 @@ module Homebrew
skip_link: false, skip_link: false,
overwrite: false overwrite: false
) )
# head-only without --HEAD is an error # HEAD-only without --HEAD is an error
if !head && formula.stable.nil? if !head && formula.stable.nil?
odie <<~EOS odie <<~EOS
#{formula.full_name} is a head-only formula. #{formula.full_name} is a HEAD-only formula.
To install it, run: To install it, run:
brew install --HEAD #{formula.full_name} brew install --HEAD #{formula.full_name}
EOS EOS

View File

@ -286,7 +286,7 @@ module Language
def slice_resources!(resources_hash, resource_names) def slice_resources!(resources_hash, resource_names)
resource_names.map do |resource_name| resource_names.map do |resource_name|
resources_hash.delete(resource_name) do resources_hash.delete(resource_name) do
raise ArgumentError, "Resource \"#{resource_name}\" is not defined in formula or is already used" raise ArgumentError, "Resource \"#{resource_name}\" is not defined in formula or is already used."
end end
end end
end end

View File

@ -245,7 +245,7 @@ module Homebrew
end end
# Use the `stable` version for comparison except for installed # Use the `stable` version for comparison except for installed
# head-only formulae. A formula with `stable` and `head` that's # HEAD-only formulae. A formula with `stable` and `head` that's
# installed using `--head` will still use the `stable` version for # installed using `--head` will still use the `stable` version for
# comparison. # comparison.
current = if formula current = if formula

View File

@ -24,7 +24,7 @@ module Patch
when nil when nil
raise ArgumentError, "nil value for strip" raise ArgumentError, "nil value for strip"
else else
raise ArgumentError, "Unexpected value #{strip.inspect} for strip" raise ArgumentError, "Unexpected value for strip: #{strip.inspect}"
end end
end end
end end

View File

@ -45,16 +45,16 @@ module Homebrew
def audit_version def audit_version
if version.nil? if version.nil?
problem "missing version" problem "Missing version"
elsif owner.is_a?(Formula) && !version.to_s.match?(GitHubPackages::VALID_OCI_TAG_REGEX) && elsif owner.is_a?(Formula) && !version.to_s.match?(GitHubPackages::VALID_OCI_TAG_REGEX) &&
(owner.core_formula? || (owner.core_formula? ||
(owner.bottle_defined? && GitHubPackages::URL_REGEX.match?(owner.bottle_specification.root_url))) (owner.bottle_defined? && GitHubPackages::URL_REGEX.match?(owner.bottle_specification.root_url)))
problem "version #{version} does not match #{GitHubPackages::VALID_OCI_TAG_REGEX.source}" problem "`version #{version}` does not match #{GitHubPackages::VALID_OCI_TAG_REGEX.source}"
elsif !version.detected_from_url? elsif !version.detected_from_url?
version_text = version version_text = version
version_url = Version.detect(url, **specs) version_url = Version.detect(url, **specs)
if version_url.to_s == version_text.to_s && version.instance_of?(Version) if version_url.to_s == version_text.to_s && version.instance_of?(Version)
problem "version #{version_text} is redundant with version scanned from URL" problem "`version #{version_text}` is redundant with version scanned from URL"
end end
end end
end end
@ -137,7 +137,7 @@ module Homebrew
# TODO: try remove the OS/env conditional # TODO: try remove the OS/env conditional
if Homebrew::SimulateSystem.simulating_or_running_on_macos? && spec_name == :stable && if Homebrew::SimulateSystem.simulating_or_running_on_macos? && spec_name == :stable &&
owner.name != "ca-certificates" && curl_dep && !urls.find { |u| u.start_with?("http://") } owner.name != "ca-certificates" && curl_dep && !urls.find { |u| u.start_with?("http://") }
problem "should always include at least one HTTP mirror" problem "Should always include at least one HTTP mirror"
end end
return unless @online return unless @online

View File

@ -258,7 +258,7 @@ class Sandbox
invalid_char = ['"', "'", "(", ")", "\n", "\\"].find do |c| invalid_char = ['"', "'", "(", ")", "\n", "\\"].find do |c|
path.to_s.include?(c) path.to_s.include?(c)
end end
raise ArgumentError, "Invalid character #{invalid_char} in path: #{path}" if invalid_char raise ArgumentError, "Invalid character '#{invalid_char}' in path: #{path}" if invalid_char
case type case type
when :regex then "regex #\"#{path}\"" when :regex then "regex #\"#{path}\""

View File

@ -164,7 +164,7 @@ module Homebrew
@keep_alive = { always: value } @keep_alive = { always: value }
when Hash when Hash
unless (value.keys - KEEP_ALIVE_KEYS).empty? unless (value.keys - KEEP_ALIVE_KEYS).empty?
raise TypeError, "Service#keep_alive allows only #{KEEP_ALIVE_KEYS}" raise TypeError, "Service#keep_alive only allows: #{KEEP_ALIVE_KEYS}"
end end
@keep_alive = value @keep_alive = value

View File

@ -43,7 +43,7 @@ module Homebrew
# Check if formula has been found. # Check if formula has been found.
def self.check!(targets) def self.check!(targets)
raise UsageError, "Formula(e) missing, please provide a formula name or use --all" if targets.empty? raise UsageError, "Formula(e) missing, please provide a formula name or use `--all`." if targets.empty?
true true
end end
@ -71,7 +71,7 @@ module Homebrew
Dir["#{System.path}homebrew.*.{plist,service}"].each do |file| Dir["#{System.path}homebrew.*.{plist,service}"].each do |file|
next if running.include?(File.basename(file).sub(/\.(plist|service)$/i, "")) next if running.include?(File.basename(file).sub(/\.(plist|service)$/i, ""))
puts "Removing unused service file #{file}" puts "Removing unused service file: #{file}"
rm file rm file
cleaned << file cleaned << file
end end
@ -90,7 +90,7 @@ module Homebrew
def self.run(targets, service_file = nil, verbose: false) def self.run(targets, service_file = nil, verbose: false)
if service_file.present? if service_file.present?
file = Pathname.new service_file file = Pathname.new service_file
raise UsageError, "Provided service file does not exist" unless file.exist? raise UsageError, "Provided service file does not exist." unless file.exist?
end end
targets.each do |service| targets.each do |service|
@ -119,7 +119,7 @@ module Homebrew
if service_file.present? if service_file.present?
file = Pathname.new service_file file = Pathname.new service_file
raise UsageError, "Provided service file does not exist" unless file.exist? raise UsageError, "Provided service file does not exist." unless file.exist?
end end
targets.each do |service| targets.each do |service|
@ -373,11 +373,11 @@ module Homebrew
end end
def self.install_service_file(service, file) def self.install_service_file(service, file)
raise UsageError, "Formula `#{service.name}` is not installed" unless service.installed? raise UsageError, "Formula `#{service.name}` is not installed." unless service.installed?
unless service.service_file.exist? unless service.service_file.exist?
raise UsageError, raise UsageError,
"Formula `#{service.name}` has not implemented #plist, #service or installed a locatable service file" "Formula `#{service.name}` has not implemented #plist, #service or provided a locatable service file."
end end
temp = Tempfile.new(service.service_name) temp = Tempfile.new(service.service_name)
@ -386,7 +386,7 @@ module Homebrew
if sudo_service_user && System.launchctl? if sudo_service_user && System.launchctl?
# set the username in the new plist file # set the username in the new plist file
ohai "Setting username in #{service.service_name} to #{System.user}" ohai "Setting username in #{service.service_name} to: #{System.user}"
plist_data = Plist.parse_xml(contents, marshal: false) plist_data = Plist.parse_xml(contents, marshal: false)
plist_data["UserName"] = sudo_service_user plist_data["UserName"] = sudo_service_user
plist_data.to_plist plist_data.to_plist

View File

@ -35,5 +35,5 @@ fi
try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@" try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@"
safe_exec "/usr/bin/curl" "$@" safe_exec "/usr/bin/curl" "$@"
echo "Could not execute curl. Try HOMEBREW_FORCE_BREWED_CURL=1" >&2 echo "Could not execute curl. Try setting HOMEBREW_FORCE_BREWED_CURL=1" >&2
exit 1 exit 1

View File

@ -1,12 +1,12 @@
#!/bin/bash -p #!/bin/bash -p
# This script because we support $HOMEBREW_GIT, $HOMEBREW_SVN, etc., Xcode-only and # This script exists because we support $HOMEBREW_GIT, $HOMEBREW_SVN etc., and Xcode-only
# no Xcode/CLT configurations. Order is careful to be what the user would want. # or no Xcode/CLT configurations. Order is careful to be what the user would want.
# HOMEBREW_LIBRARY is set by bin/brew # HOMEBREW_LIBRARY is set by bin/brew
# SHIM_FILE is set by shims/utils.sh # SHIM_FILE is set by shims/utils.sh
# HOMEBREW_GIT is set by brew.sh # HOMEBREW_GIT is set by brew.sh
# HOMEBREW_SVN is from the user environment. # HOMEBREW_SVN is from the user environment
# HOMEBREW_PREFIX is set by extend/ENV/super.rb # HOMEBREW_PREFIX is set by extend/ENV/super.rb
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ -z "${HOMEBREW_LIBRARY}" ]] if [[ -z "${HOMEBREW_LIBRARY}" ]]

View File

@ -834,7 +834,7 @@ RSpec.describe Homebrew::FormulaAuditor do
RUBY RUBY
fa.audit_specs fa.audit_specs
expect(fa.problems.first[:message]).to match "should only be updated every 10 releases on multiples of 10" expect(fa.problems.first[:message]).to match "Should only be updated every 10 releases on multiples of 10"
end end
it "allows non-versioned formulae to have a `HEAD` spec" do it "allows non-versioned formulae to have a `HEAD` spec" do

View File

@ -68,7 +68,7 @@ RSpec.describe Formula do
end.to fail_with_invalid :version end.to fail_with_invalid :version
end end
specify "head-only is valid" do specify "HEAD-only is valid" do
f = formula do f = formula do
head "foo" head "foo"
end end

View File

@ -68,7 +68,7 @@ RSpec.describe Homebrew::Service do
expect do expect do
f.service.manual_command f.service.manual_command
end.to raise_error TypeError, "Service#keep_alive allows only [:always, :successful_exit, :crashed, :path]" end.to raise_error TypeError, "Service#keep_alive only allows: [:always, :successful_exit, :crashed, :path]"
end end
end end

View File

@ -46,14 +46,15 @@ RSpec.describe Homebrew::Services::Cli do
it "checks the input does not exist" do it "checks the input does not exist" do
expect do expect do
services_cli.check!([]) services_cli.check!([])
end.to raise_error(UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all") end.to raise_error(UsageError,
"Invalid usage: Formula(e) missing, please provide a formula name or use `--all`.")
end end
it "checks the input exists" do it "checks the input exists" do
expect do expect do
services_cli.check!("hello") services_cli.check!("hello")
end.not_to raise_error(UsageError, end.not_to raise_error(UsageError,
"Invalid usage: Formula(e) missing, please provide a formula name or use --all") "Invalid usage: Formula(e) missing, please provide a formula name or use `--all`.")
end end
end end
@ -88,7 +89,7 @@ RSpec.describe Homebrew::Services::Cli do
expect(Homebrew::Services::System).not_to receive(:root?) expect(Homebrew::Services::System).not_to receive(:root?)
expect do expect do
services_cli.start(["service_name"], "/non/existent/path") services_cli.start(["service_name"], "/non/existent/path")
end.to raise_error(UsageError, "Invalid usage: Provided service file does not exist") end.to raise_error(UsageError, "Invalid usage: Provided service file does not exist.")
end end
it "checks empty targets cause no error" do it "checks empty targets cause no error" do
@ -111,7 +112,7 @@ RSpec.describe Homebrew::Services::Cli do
expect(Homebrew::Services::System).not_to receive(:root?) expect(Homebrew::Services::System).not_to receive(:root?)
expect do expect do
services_cli.start(["service_name"], "/hfdkjshksdjhfkjsdhf/fdsjghsdkjhb") services_cli.start(["service_name"], "/hfdkjshksdjhfkjsdhf/fdsjghsdkjhb")
end.to raise_error(UsageError, "Invalid usage: Provided service file does not exist") end.to raise_error(UsageError, "Invalid usage: Provided service file does not exist.")
end end
it "checks empty targets cause no error" do it "checks empty targets cause no error" do
@ -164,7 +165,7 @@ RSpec.describe Homebrew::Services::Cli do
service = instance_double(Homebrew::Services::FormulaWrapper, name: "name", installed?: false) service = instance_double(Homebrew::Services::FormulaWrapper, name: "name", installed?: false)
expect do expect do
services_cli.install_service_file(service, nil) services_cli.install_service_file(service, nil)
end.to raise_error(UsageError, "Invalid usage: Formula `name` is not installed") end.to raise_error(UsageError, "Invalid usage: Formula `name` is not installed.")
end end
it "checks service file exists" do it "checks service file exists" do
@ -178,7 +179,7 @@ RSpec.describe Homebrew::Services::Cli do
services_cli.install_service_file(service, nil) services_cli.install_service_file(service, nil)
end.to raise_error( end.to raise_error(
UsageError, UsageError,
"Invalid usage: Formula `name` has not implemented #plist, #service or installed a locatable service file", "Invalid usage: Formula `name` has not implemented #plist, #service or provided a locatable service file.",
) )
end end
end end

View File

@ -17,7 +17,8 @@ RSpec.describe Homebrew::Services::Commands::Info do
it "fails with empty list" do it "fails with empty list" do
expect do expect do
described_class.run([], verbose: false, json: false) described_class.run([], verbose: false, json: false)
end.to raise_error UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all" end.to raise_error UsageError,
"Invalid usage: Formula(e) missing, please provide a formula name or use `--all`."
end end
it "succeeds with items" do it "succeeds with items" do

View File

@ -13,7 +13,8 @@ RSpec.describe Homebrew::Services::Commands::Restart do
it "fails with empty list" do it "fails with empty list" do
expect do expect do
described_class.run([], nil, verbose: false) described_class.run([], nil, verbose: false)
end.to raise_error UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all" end.to raise_error UsageError,
"Invalid usage: Formula(e) missing, please provide a formula name or use `--all`."
end end
it "starts if services are not loaded" do it "starts if services are not loaded" do

View File

@ -104,7 +104,7 @@ RSpec.describe Version do
it "raises an error" do it "raises an error" do
expect do expect do
null_version.to_str null_version.to_str
end.to raise_error NoMethodError, "undefined method `to_str' for Version:NULL" end.to raise_error NoMethodError, "undefined method `to_str` for Version:NULL"
end end
end end

View File

@ -123,7 +123,7 @@ module GitHub
end end
end end
# Error when the user has no GitHub API credentials set at all (macOS keychain, GitHub CLI or envvar). # Error when the user has no GitHub API credentials set at all (macOS keychain, GitHub CLI or env var).
class MissingAuthenticationError < Error class MissingAuthenticationError < Error
sig { void } sig { void }
def initialize def initialize

View File

@ -723,7 +723,7 @@ class Version
# @api public # @api public
sig { returns(String) } sig { returns(String) }
def to_str def to_str
raise NoMethodError, "undefined method `to_str' for #{self.class}:NULL" if null? raise NoMethodError, "undefined method `to_str` for #{self.class}:NULL" if null?
T.must(version).to_str T.must(version).to_str
end end

View File

@ -1909,9 +1909,9 @@ _brew_search() {
# brew services # brew services
_brew_services() { _brew_services() {
_arguments \ _arguments \
'--all[Run subcommand on all services]' \ '(--file)--all[Run subcommand on all services]' \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'--file[Use the service file from this location to `start` the service]' \ '(--all)--file[Use the service file from this location to `start` the service]' \
'--help[Show this message]' \ '--help[Show this message]' \
'--json[Output as JSON]' \ '--json[Output as JSON]' \
'--keep[When stopped, don'\''t unregister the service from launching at login (or boot)]' \ '--keep[When stopped, don'\''t unregister the service from launching at login (or boot)]' \

View File

@ -1411,26 +1411,26 @@ If `sudo` is passed, operate on `/Library/LaunchDaemons` or
`/usr/lib/systemd/system` (started at boot). Otherwise, operate on `/usr/lib/systemd/system` (started at boot). Otherwise, operate on
`~/Library/LaunchAgents` or `~/.config/systemd/user` (started at login). `~/Library/LaunchAgents` or `~/.config/systemd/user` (started at login).
\[`sudo`\] `brew services` \[`list`\] (`--json`) (`--debug`) \[`sudo`\] `brew services` \[`list`\] \[`--json`\] \[`--debug`\]
: List information about all managed services for the current user (or root). : List information about all managed services for the current user (or root).
Provides more output from Homebrew and `launchctl`(1) or `systemctl`(1) if run Provides more output from Homebrew and `launchctl`(1) or `systemctl`(1) if run
with `--debug`. with `--debug`.
\[`sudo`\] `brew services info` (*`formula`*\|`--all`\|`--json`) \[`sudo`\] `brew services info` (*`formula`*\|`--all`) \[`--json`\]
: List all managed services for the current user (or root). : List all managed services for the current user (or root).
\[`sudo`\] `brew services run` (*`formula`*\|`--all`\|`--file=`) \[`sudo`\] `brew services run` (*`formula`*\|`--all`) \[`--file=`\]
: Run the service *`formula`* without registering to launch at login (or boot). : Run the service *`formula`* without registering to launch at login (or boot).
\[`sudo`\] `brew services start` (*`formula`*\|`--all`\|`--file=`) \[`sudo`\] `brew services start` (*`formula`*\|`--all`) \[`--file=`\]
: Start the service *`formula`* immediately and register it to launch at login : Start the service *`formula`* immediately and register it to launch at login
(or boot). (or boot).
\[`sudo`\] `brew services stop` (`--keep`) (`--no-wait`\|`--max-wait=`) (*`formula`*\|`--all`) \[`sudo`\] `brew services stop` \[`--keep`\] \[`--no-wait`\|`--max-wait=`\] (*`formula`*\|`--all`)
: Stop the service *`formula`* immediately and unregister it from launching at : Stop the service *`formula`* immediately and unregister it from launching at
login (or boot), unless `--keep` is specified. login (or boot), unless `--keep` is specified.
@ -1440,7 +1440,7 @@ If `sudo` is passed, operate on `/Library/LaunchDaemons` or
: Stop the service *`formula`* immediately but keep it registered to launch at : Stop the service *`formula`* immediately but keep it registered to launch at
login (or boot). login (or boot).
\[`sudo`\] `brew services restart` (*`formula`*\|`--all`\|`--file=`) \[`sudo`\] `brew services restart` (*`formula`*\|`--all`) \[`--file=`\]
: Stop (if necessary) and start the service *`formula`* immediately and register : Stop (if necessary) and start the service *`formula`* immediately and register
it to launch at login (or boot). it to launch at login (or boot).
@ -1462,14 +1462,6 @@ If `sudo` is passed, operate on `/Library/LaunchDaemons` or
: Wait at most this many seconds for `stop` to finish stopping a service. : Wait at most this many seconds for `stop` to finish stopping a service.
Defaults to 60. Set this to zero (0) seconds to wait indefinitely. Defaults to 60. Set this to zero (0) seconds to wait indefinitely.
`--all`
: Run *`subcommand`* on all services.
`--json`
: Output as JSON.
`--no-wait` `--no-wait`
: Don't wait for `stop` to finish stopping the service. : Don't wait for `stop` to finish stopping the service.
@ -1478,6 +1470,14 @@ If `sudo` is passed, operate on `/Library/LaunchDaemons` or
: When stopped, don't unregister the service from launching at login (or boot). : When stopped, don't unregister the service from launching at login (or boot).
`--all`
: Run *`subcommand`* on all services.
`--json`
: Output as JSON.
### `setup-ruby` \[*`command`* ...\] ### `setup-ruby` \[*`command`* ...\]
Installs and configures Homebrew's Ruby. If `command` is passed, it will only Installs and configures Homebrew's Ruby. If `command` is passed, it will only

View File

@ -879,25 +879,25 @@ Manage background services with macOS\[u2019] \fBlaunchctl\fP(1) daemon manager
.P .P
If \fBsudo\fP is passed, operate on \fB/Library/LaunchDaemons\fP or \fB/usr/lib/systemd/system\fP (started at boot)\. Otherwise, operate on \fB~/Library/LaunchAgents\fP or \fB~/\.config/systemd/user\fP (started at login)\. If \fBsudo\fP is passed, operate on \fB/Library/LaunchDaemons\fP or \fB/usr/lib/systemd/system\fP (started at boot)\. Otherwise, operate on \fB~/Library/LaunchAgents\fP or \fB~/\.config/systemd/user\fP (started at login)\.
.TP .TP
[\fBsudo\fP] \fBbrew services\fP [\fBlist\fP] (\fB\-\-json\fP) (\fB\-\-debug\fP) [\fBsudo\fP] \fBbrew services\fP [\fBlist\fP] [\fB\-\-json\fP] [\fB\-\-debug\fP]
List information about all managed services for the current user (or root)\. Provides more output from Homebrew and \fBlaunchctl\fP(1) or \fBsystemctl\fP(1) if run with \fB\-\-debug\fP\&\. List information about all managed services for the current user (or root)\. Provides more output from Homebrew and \fBlaunchctl\fP(1) or \fBsystemctl\fP(1) if run with \fB\-\-debug\fP\&\.
.TP .TP
[\fBsudo\fP] \fBbrew services info\fP (\fIformula\fP|\fB\-\-all\fP|\fB\-\-json\fP) [\fBsudo\fP] \fBbrew services info\fP (\fIformula\fP|\fB\-\-all\fP) [\fB\-\-json\fP]
List all managed services for the current user (or root)\. List all managed services for the current user (or root)\.
.TP .TP
[\fBsudo\fP] \fBbrew services run\fP (\fIformula\fP|\fB\-\-all\fP|\fB\-\-file=\fP) [\fBsudo\fP] \fBbrew services run\fP (\fIformula\fP|\fB\-\-all\fP) [\fB\-\-file=\fP]
Run the service \fIformula\fP without registering to launch at login (or boot)\. Run the service \fIformula\fP without registering to launch at login (or boot)\.
.TP .TP
[\fBsudo\fP] \fBbrew services start\fP (\fIformula\fP|\fB\-\-all\fP|\fB\-\-file=\fP) [\fBsudo\fP] \fBbrew services start\fP (\fIformula\fP|\fB\-\-all\fP) [\fB\-\-file=\fP]
Start the service \fIformula\fP immediately and register it to launch at login (or boot)\. Start the service \fIformula\fP immediately and register it to launch at login (or boot)\.
.TP .TP
[\fBsudo\fP] \fBbrew services stop\fP (\fB\-\-keep\fP) (\fB\-\-no\-wait\fP|\fB\-\-max\-wait=\fP) (\fIformula\fP|\fB\-\-all\fP) [\fBsudo\fP] \fBbrew services stop\fP [\fB\-\-keep\fP] [\fB\-\-no\-wait\fP|\fB\-\-max\-wait=\fP] (\fIformula\fP|\fB\-\-all\fP)
Stop the service \fIformula\fP immediately and unregister it from launching at login (or boot), unless \fB\-\-keep\fP is specified\. Stop the service \fIformula\fP immediately and unregister it from launching at login (or boot), unless \fB\-\-keep\fP is specified\.
.TP .TP
[\fBsudo\fP] \fBbrew services kill\fP (\fIformula\fP|\fB\-\-all\fP) [\fBsudo\fP] \fBbrew services kill\fP (\fIformula\fP|\fB\-\-all\fP)
Stop the service \fIformula\fP immediately but keep it registered to launch at login (or boot)\. Stop the service \fIformula\fP immediately but keep it registered to launch at login (or boot)\.
.TP .TP
[\fBsudo\fP] \fBbrew services restart\fP (\fIformula\fP|\fB\-\-all\fP|\fB\-\-file=\fP) [\fBsudo\fP] \fBbrew services restart\fP (\fIformula\fP|\fB\-\-all\fP) [\fB\-\-file=\fP]
Stop (if necessary) and start the service \fIformula\fP immediately and register it to launch at login (or boot)\. Stop (if necessary) and start the service \fIformula\fP immediately and register it to launch at login (or boot)\.
.TP .TP
[\fBsudo\fP] \fBbrew services cleanup\fP [\fBsudo\fP] \fBbrew services cleanup\fP
@ -912,17 +912,17 @@ When run as root on macOS, run the service(s) as this user\.
\fB\-\-max\-wait\fP \fB\-\-max\-wait\fP
Wait at most this many seconds for \fBstop\fP to finish stopping a service\. Defaults to 60\. Set this to zero (0) seconds to wait indefinitely\. Wait at most this many seconds for \fBstop\fP to finish stopping a service\. Defaults to 60\. Set this to zero (0) seconds to wait indefinitely\.
.TP .TP
\fB\-\-all\fP
Run \fIsubcommand\fP on all services\.
.TP
\fB\-\-json\fP
Output as JSON\.
.TP
\fB\-\-no\-wait\fP \fB\-\-no\-wait\fP
Don\[u2019]t wait for \fBstop\fP to finish stopping the service\. Don\[u2019]t wait for \fBstop\fP to finish stopping the service\.
.TP .TP
\fB\-\-keep\fP \fB\-\-keep\fP
When stopped, don\[u2019]t unregister the service from launching at login (or boot)\. When stopped, don\[u2019]t unregister the service from launching at login (or boot)\.
.TP
\fB\-\-all\fP
Run \fIsubcommand\fP on all services\.
.TP
\fB\-\-json\fP
Output as JSON\.
.SS "\fBsetup\-ruby\fP \fR[\fIcommand\fP \.\.\.]" .SS "\fBsetup\-ruby\fP \fR[\fIcommand\fP \.\.\.]"
Installs and configures Homebrew\[u2019]s Ruby\. If \fBcommand\fP is passed, it will only run Bundler if necessary for that command\. Installs and configures Homebrew\[u2019]s Ruby\. If \fBcommand\fP is passed, it will only run Bundler if necessary for that command\.
.SS "\fBshellenv\fP \fR[\fIshell\fP \.\.\.]" .SS "\fBshellenv\fP \fR[\fIshell\fP \.\.\.]"