Merge pull request #10412 from EricFromCanada/adjust-messaging

Adjustments for message output
This commit is contained in:
Eric Knibbe 2021-01-26 16:50:23 -05:00 committed by GitHub
commit f7a718c1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
128 changed files with 422 additions and 409 deletions

View File

@ -92,7 +92,7 @@ odie() {
} }
safe_cd() { safe_cd() {
cd "$@" >/dev/null || odie "Error: failed to cd to $*!" cd "$@" >/dev/null || odie "Failed to cd to $*!"
} }
brew() { brew() {
@ -382,10 +382,10 @@ else
curl_name_and_version="${curl_version_output%% (*}" curl_name_and_version="${curl_version_output%% (*}"
if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]] if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]]
then then
message="Please update your system cURL. message="Please update your system curl.
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 || -z $HOMEBREW_DEVELOPER ]]; then if [[ -z $HOMEBREW_CURL_PATH || -z $HOMEBREW_DEVELOPER ]]; then
HOMEBREW_SYSTEM_CURL_TOO_OLD=1 HOMEBREW_SYSTEM_CURL_TOO_OLD=1

View File

@ -152,14 +152,18 @@ class Build
system "git", "add", "-A" system "git", "add", "-A"
end end
if args.interactive? if args.interactive?
ohai "Entering interactive mode" ohai "Entering interactive mode..."
puts "Type `exit` to return and finalize the installation." puts <<~EOS
puts "Install to this prefix: #{formula.prefix}" Type `exit` to return and finalize the installation.
Install to this prefix: #{formula.prefix}
EOS
if args.git? if args.git?
puts "This directory is now a git repo. Make your changes and then use:" puts <<~EOS
puts " git diff | pbcopy" This directory is now a Git repository. Make your changes and then use:
puts "to copy the diff to the clipboard." git diff | pbcopy
to copy the diff to the clipboard.
EOS
end end
interactive_shell(formula) interactive_shell(formula)

View File

@ -133,8 +133,11 @@ module Cask
sig { returns(String) } sig { returns(String) }
def automation_access_instructions def automation_access_instructions
"Enable Automation Access for “Terminal > System Events” in " \ <<~EOS
"“System Preferences > Security > Privacy > Automation” if you haven't already." Enable Automation access for "Terminal → System Events" in:
System Preferences Security & Privacy Privacy Automation
if you haven't already.
EOS
end end
# :quit/:signal must come before :kext so the kext will not be in use by a running process # :quit/:signal must come before :kext so the kext will not be in use by a running process
@ -300,7 +303,7 @@ module Cask
message = "uninstall script #{executable} does not exist" message = "uninstall script #{executable} does not exist"
raise CaskError, "#{message}." unless force raise CaskError, "#{message}." unless force
opoo "#{message}, skipping." opoo "#{message}; skipping."
return return
end end
@ -367,8 +370,7 @@ module Cask
resolved_paths = each_resolved_path(:trash, paths).to_a resolved_paths = each_resolved_path(:trash, paths).to_a
ohai "Trashing files:" ohai "Trashing files:", resolved_paths.map(&:first)
puts resolved_paths.map(&:first)
trash_paths(*resolved_paths.flat_map(&:last), **options) trash_paths(*resolved_paths.flat_map(&:last), **options)
end end
@ -396,7 +398,7 @@ module Cask
false false
end end
opoo "The following files could not trashed, please do so manually:" opoo "The following files could not be trashed, please do so manually:"
$stderr.puts untrashable $stderr.puts untrashable
[trashed, untrashable] [trashed, untrashable]

View File

@ -23,7 +23,7 @@ module Cask
puts <<~EOS puts <<~EOS
To complete the installation of Cask #{cask}, you must also To complete the installation of Cask #{cask}, you must also
run the installer at: run the installer at:
'#{cask.staged_path.join(path)}' #{cask.staged_path.join(path)}
EOS EOS
end end
end end

View File

@ -48,7 +48,7 @@ module Cask
raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there." raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there."
end end
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'." ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
if target.dirname.ascend.find(&:directory?).writable? if target.dirname.ascend.find(&:directory?).writable?
target.dirname.mkpath target.dirname.mkpath
else else
@ -84,7 +84,7 @@ module Cask
raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there." raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there."
end end
ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'." ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'"
source.dirname.mkpath source.dirname.mkpath
# We need to preserve extended attributes between copies. # We need to preserve extended attributes between copies.
@ -94,7 +94,7 @@ module Cask
end end
def delete(target, force: false, command: nil, **_) def delete(target, force: false, command: nil, **_)
ohai "Removing #{self.class.english_name} '#{target}'." ohai "Removing #{self.class.english_name} '#{target}'"
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target) raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target)
return unless Utils.path_occupied?(target) return unless Utils.path_occupied?(target)

View File

@ -39,8 +39,8 @@ 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}; your password may be necessary." ohai "Running installer for #{cask}; your password may be necessary.",
ohai "Package installers may write to any location; options such as --appdir are ignored." "Package installers may write to any location; options such as `--appdir` are ignored."
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

@ -82,7 +82,7 @@ module Cask
altnames = command.run("/usr/bin/xattr", altnames = command.run("/usr/bin/xattr",
args: ["-p", ALT_NAME_ATTRIBUTE, file], args: ["-p", ALT_NAME_ATTRIBUTE, file],
print_stderr: false).stdout.sub(/\A\((.*)\)\Z/, '\1') print_stderr: false).stdout.sub(/\A\((.*)\)\Z/, '\1')
odebug "Existing metadata is: '#{altnames}'" odebug "Existing metadata is: #{altnames}"
altnames.concat(", ") unless altnames.empty? altnames.concat(", ") unless altnames.empty?
altnames.concat(%Q("#{altname}")) altnames.concat(%Q("#{altname}"))
altnames = "(#{altnames})" altnames = "(#{altnames})"

View File

@ -65,14 +65,14 @@ module Cask
end end
end end
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'." ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'"
create_filesystem_link(**options) create_filesystem_link(**options)
end end
def unlink(**) def unlink(**)
return unless target.symlink? return unless target.symlink?
ohai "Unlinking #{self.class.english_name} '#{target}'." ohai "Unlinking #{self.class.english_name} '#{target}'"
target.delete target.delete
end end

View File

@ -82,7 +82,7 @@ module Cask
check_bitbucket_repository check_bitbucket_repository
self self
rescue => e rescue => e
odebug "#{e.message}\n#{e.backtrace.join("\n")}" odebug e, e.backtrace
add_error "exception while auditing #{cask}: #{e.message}" add_error "exception while auditing #{cask}: #{e.message}"
self self
end end
@ -416,7 +416,7 @@ module Cask
return unless verified_matches_url? return unless verified_matches_url?
add_error "The URL's domain #{domain} matches the homepage domain #{homepage}, " \ add_error "The URL's domain #{domain} matches the homepage domain #{homepage}, " \
"the `verified` parameter of the `url` stanza is unnecessary. " \ "the 'verified' parameter of the 'url' stanza is unnecessary. " \
"See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-verified" "See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-verified"
end end
@ -427,7 +427,7 @@ module Cask
return if verified_present? return if verified_present?
add_error "The URL's domain #{domain} does not match the homepage domain #{homepage}, " \ add_error "The URL's domain #{domain} does not match the homepage domain #{homepage}, " \
"a `verified` parameter has to be added to the `url` stanza. " \ "a 'verified' parameter has to be added to the 'url' stanza. " \
"See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-verified" "See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-verified"
end end

View File

@ -115,7 +115,7 @@ module Cask
path.dirname.mkpath path.dirname.mkpath
begin begin
ohai "Downloading #{url}." ohai "Downloading #{url}"
curl_download url, to: path curl_download url, to: path
rescue ErrorDuringExecution rescue ErrorDuringExecution
raise CaskUnavailableError.new(token, "Failed to download #{Formatter.url(url)}.") raise CaskUnavailableError.new(token, "Failed to download #{Formatter.url(url)}.")

View File

@ -22,8 +22,8 @@ module Cask
sudo = !path.parent.writable? sudo = !path.parent.writable?
if sudo && !ENV.key?("SUDO_ASKPASS") && $stdout.tty? if sudo && !ENV.key?("SUDO_ASKPASS") && $stdout.tty?
ohai "Creating Caskroom at #{path}" ohai "Creating Caskroom directory: #{path}",
ohai "We'll set permissions properly so we won't need sudo in the future." "We'll set permissions properly so we won't need sudo in the future."
end end
SystemCommand.run("/bin/mkdir", args: ["-p", path], sudo: sudo) SystemCommand.run("/bin/mkdir", args: ["-p", path], sudo: sudo)

View File

@ -174,7 +174,7 @@ module Cask
[args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv] [args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv]
if (replacement = DEPRECATED_COMMANDS[command]) if (replacement = DEPRECATED_COMMANDS[command])
odisabled "brew cask #{command.command_name}", replacement odisabled "`brew cask #{command.command_name}`", replacement
end end
if args.help? if args.help?

View File

@ -129,7 +129,7 @@ module Cask
matches = search_casks(cask_token) matches = search_casks(cask_token)
if matches.one? if matches.one?
"Did you mean #{matches.first}?" "Did you mean '#{matches.first}'?"
elsif !matches.empty? elsif !matches.empty?
"Did you mean one of these?\n#{Formatter.columns(matches.take(20))}" "Did you mean one of these?\n#{Formatter.columns(matches.take(20))}"
end end

View File

@ -43,7 +43,7 @@ module Cask
download = Download.new(cask, **options) download = Download.new(cask, **options)
download.clear_cache if args.force? download.clear_cache if args.force?
downloaded_path = download.fetch downloaded_path = download.fetch
ohai "Success! Downloaded to -> #{downloaded_path}" ohai "Success! Downloaded to: #{downloaded_path}"
end end
end end
end end

View File

@ -80,7 +80,7 @@ module Cask
return if DSL::DSL_METHODS.include?(stanza) return if DSL::DSL_METHODS.include?(stanza)
raise UsageError, <<~EOS raise UsageError, <<~EOS
Unknown/unsupported stanza: '#{stanza}' Unknown/unsupported stanza '#{stanza}'.
Check cask reference for supported stanzas. Check cask reference for supported stanzas.
EOS EOS
end end
@ -98,7 +98,7 @@ module Cask
begin begin
value = cask.send(stanza) value = cask.send(stanza)
rescue rescue
opoo "failure calling '#{stanza}' on Cask '#{cask}'" unless args.quiet? opoo "Failure calling '#{stanza}' on Cask '#{cask}'" unless args.quiet?
puts "" puts ""
next next
end end

View File

@ -101,7 +101,7 @@ module Cask
return false if outdated_casks.empty? return false if outdated_casks.empty?
if casks.empty? && !greedy if casks.empty? && !greedy
ohai "Casks with `auto_updates` or `version :latest` will not be upgraded; pass `--greedy` to upgrade them." ohai "Casks with 'auto_updates' or 'version :latest' will not be upgraded; pass `--greedy` to upgrade them."
end end
verb = dry_run ? "Would upgrade" : "Upgrading" verb = dry_run ? "Would upgrade" : "Upgrading"

View File

@ -63,7 +63,7 @@ module Cask
end end
begin begin
ohai "Verifying checksum for cask '#{@cask}'." if verbose? ohai "Verifying checksum for cask '#{@cask}'" if verbose?
fn.verify_checksum(@cask.sha256) fn.verify_checksum(@cask.sha256)
rescue ChecksumMissingError rescue ChecksumMissingError
opoo <<~EOS opoo <<~EOS

View File

@ -201,7 +201,7 @@ module Cask
def version(arg = nil) def version(arg = nil)
set_unique_stanza(:version, arg.nil?) do set_unique_stanza(:version, arg.nil?) do
if !arg.is_a?(String) && arg != :latest if !arg.is_a?(String) && arg != :latest
raise CaskInvalidError.new(cask, "invalid 'version' value: '#{arg.inspect}'") raise CaskInvalidError.new(cask, "invalid 'version' value: #{arg.inspect}")
end end
DSL::Version.new(arg) DSL::Version.new(arg)
@ -216,7 +216,7 @@ module Cask
when String when String
Checksum.new(arg) Checksum.new(arg)
else else
raise CaskInvalidError.new(cask, "invalid 'sha256' value: '#{arg.inspect}'") raise CaskInvalidError.new(cask, "invalid 'sha256' value: #{arg.inspect}")
end end
end end
end end

View File

@ -69,22 +69,22 @@ module Cask
end end
caveat :unsigned_accessibility do |access = "Accessibility"| caveat :unsigned_accessibility do |access = "Accessibility"|
# access: the category in System Preferences -> Security & Privacy -> Privacy the app requires. # access: the category in System Preferences > Security & Privacy > Privacy the app requires.
<<~EOS <<~EOS
#{@cask} is not signed and requires Accessibility access, #{@cask} is not signed and requires Accessibility access,
so you will need to re-grant Accessibility access every time the app is updated. so you will need to re-grant Accessibility access every time the app is updated.
Enable or re-enable it in: Enable or re-enable it in:
System Preferences Security & Privacy Privacy -> #{access} System Preferences Security & Privacy Privacy #{access}
To re-enable untick and retick #{@cask}.app. To re-enable, untick and retick #{@cask}.app.
EOS EOS
end end
caveat :path_environment_variable do |path| caveat :path_environment_variable do |path|
<<~EOS <<~EOS
To use #{@cask}, you may need to add the #{path} directory To use #{@cask}, you may need to add the #{path} directory
to your PATH environment variable, e.g. (for bash shell): to your PATH environment variable, e.g. (for Bash shell):
export PATH=#{path}:"$PATH" export PATH=#{path}:"$PATH"
EOS EOS
end end

View File

@ -19,7 +19,7 @@ module Cask
def initialize(pairs = {}) def initialize(pairs = {})
@pairs = pairs @pairs = pairs
pairs.each do |key, value| pairs.each do |key, value|
raise "invalid container key: '#{key.inspect}'" unless VALID_KEYS.include?(key) raise "invalid container key: #{key.inspect}" unless VALID_KEYS.include?(key)
send(:"#{key}=", value) send(:"#{key}=", value)
end end

View File

@ -52,7 +52,7 @@ module Cask
end end
def macos=(*args) def macos=(*args)
raise "Only a single 'depends_on macos:' is allowed." if defined?(@macos) raise "Only a single 'depends_on macos' is allowed." if defined?(@macos)
begin begin
@macos = if args.count > 1 @macos = if args.count > 1

View File

@ -212,11 +212,11 @@ module Cask
end end
def install_artifacts def install_artifacts
artifacts = @cask.artifacts
already_installed_artifacts = [] already_installed_artifacts = []
odebug "Installing artifacts" odebug "Installing artifacts"
artifacts = @cask.artifacts odebug "#{artifacts.length} #{"artifact".pluralize(artifacts.length)} defined", artifacts
odebug "#{artifacts.length} artifact/s defined", artifacts
artifacts.each do |artifact| artifacts.each do |artifact|
next unless artifact.respond_to?(:install_phase) next unless artifact.respond_to?(:install_phase)
@ -280,7 +280,7 @@ module Cask
raise CaskError, raise CaskError,
"Cask #{@cask} depends on hardware architecture being one of " \ "Cask #{@cask} depends on hardware architecture being one of " \
"[#{@cask.depends_on.arch.map(&:to_s).join(", ")}], " \ "[#{@cask.depends_on.arch.map(&:to_s).join(", ")}], " \
"but you are running #{@current_arch}" "but you are running #{@current_arch}."
end end
def x11_dependencies def x11_dependencies
@ -356,7 +356,7 @@ module Cask
missing_formulae_and_casks = missing_cask_and_formula_dependencies missing_formulae_and_casks = missing_cask_and_formula_dependencies
if missing_formulae_and_casks.empty? if missing_formulae_and_casks.empty?
puts "All Formula dependencies satisfied." puts "All formula dependencies satisfied."
return return
end end
@ -459,10 +459,10 @@ module Cask
end end
def uninstall_artifacts(clear: false) def uninstall_artifacts(clear: false)
odebug "Uninstalling artifacts"
artifacts = @cask.artifacts artifacts = @cask.artifacts
odebug "#{artifacts.length} artifact/s defined", artifacts odebug "Uninstalling artifacts"
odebug "#{artifacts.length} #{"artifact".pluralize(artifacts.length)} defined", artifacts
artifacts.each do |artifact| artifacts.each do |artifact|
if artifact.respond_to?(:uninstall_phase) if artifact.respond_to?(:uninstall_phase)
@ -482,7 +482,7 @@ module Cask
end end
def zap def zap
ohai %Q(Implied "brew uninstall --cask #{@cask}") ohai "Implied `brew uninstall --cask #{@cask}`"
uninstall_artifacts uninstall_artifacts
if (zap_stanzas = @cask.artifacts.select { |a| a.is_a?(Artifact::Zap) }).empty? if (zap_stanzas = @cask.artifacts.select { |a| a.is_a?(Artifact::Zap) }).empty?
opoo "No zap stanza present for Cask '#{@cask}'" opoo "No zap stanza present for Cask '#{@cask}'"

View File

@ -32,7 +32,7 @@ module Cask
end end
if create && !path.directory? if create && !path.directory?
odebug "Creating metadata directory #{path}." odebug "Creating metadata directory: #{path}"
path.mkpath path.mkpath
end end
@ -50,7 +50,7 @@ module Cask
subdir = parent.join(leaf) subdir = parent.join(leaf)
if create && !subdir.directory? if create && !subdir.directory?
odebug "Creating metadata subdirectory #{subdir}." odebug "Creating metadata subdirectory: #{subdir}"
subdir.mkpath subdir.mkpath
end end

View File

@ -32,7 +32,7 @@ module Cask
odebug "Checking quarantine support" odebug "Checking quarantine support"
if !system_command(xattr, print_stderr: false).success? if !system_command(xattr, print_stderr: false).success?
odebug "There's not a working version of xattr." odebug "There's no working version of `xattr` on this system."
:xattr_broken :xattr_broken
elsif swift.nil? elsif swift.nil?
odebug "Swift is not available on this system." odebug "Swift is not available on this system."

View File

@ -29,7 +29,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}; your password may be necessary" ohai "Changing ownership of paths required by #{@cask}; your password may be necessary."
@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

@ -62,7 +62,7 @@ class Caveats
if f.bin.directory? || f.sbin.directory? if f.bin.directory? || f.sbin.directory?
s << <<~EOS s << <<~EOS
If you need to have #{f.name} first in your PATH run: If you need to have #{f.name} first in your PATH, run:
EOS EOS
s << " #{Utils::Shell.prepend_path_in_profile(f.opt_bin.to_s)}\n" if f.bin.directory? s << " #{Utils::Shell.prepend_path_in_profile(f.opt_bin.to_s)}\n" if f.bin.directory?
s << " #{Utils::Shell.prepend_path_in_profile(f.opt_sbin.to_s)}\n" if f.sbin.directory? s << " #{Utils::Shell.prepend_path_in_profile(f.opt_sbin.to_s)}\n" if f.sbin.directory?

View File

@ -28,6 +28,7 @@ module Homebrew
description: "Only show cache files for formulae." description: "Only show cache files for formulae."
switch "--cask", switch "--cask",
description: "Only show cache files for casks." description: "Only show cache files for casks."
conflicts "--build-from-source", "--force-bottle" conflicts "--build-from-source", "--force-bottle"
conflicts "--formula", "--cask" conflicts "--formula", "--cask"

View File

@ -45,7 +45,7 @@ module Homebrew
when "all" when "all"
0 0
else else
raise UsageError, "--prune= expects an integer or 'all'." raise UsageError, "`--prune=` expects an integer or `all`."
end end
end end

View File

@ -61,6 +61,7 @@ module Homebrew
switch "--cask", "--casks", switch "--cask", "--casks",
depends_on: "--installed", depends_on: "--installed",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--installed", "--all" conflicts "--installed", "--all"
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
formula_options formula_options

View File

@ -57,8 +57,7 @@ module Homebrew
methods.each do |method| methods.each do |method|
$stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug? $stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug?
unless checks.respond_to?(method) unless checks.respond_to?(method)
Homebrew.failed = true ofail "No check available by the name: #{method}"
puts "No check available by the name: #{method}"
next next
end end

View File

@ -42,12 +42,10 @@ module Homebrew
switch "--[no-]quarantine", switch "--[no-]quarantine",
description: "Disable/enable quarantining of downloads (default: enabled).", description: "Disable/enable quarantining of downloads (default: enabled).",
env: :cask_opts_quarantine env: :cask_opts_quarantine
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask"
conflicts "--build-from-source", "--build-bottle", "--force-bottle" conflicts "--build-from-source", "--build-bottle", "--force-bottle"
conflicts "--cask", "--HEAD" conflicts "--cask", "--HEAD"
@ -55,6 +53,7 @@ module Homebrew
conflicts "--cask", "-s" conflicts "--cask", "-s"
conflicts "--cask", "--build-bottle" conflicts "--cask", "--build-bottle"
conflicts "--cask", "--force-bottle" conflicts "--cask", "--force-bottle"
conflicts "--formula", "--cask"
named_args [:formula, :cask], min: 1 named_args [:formula, :cask], min: 1
end end
@ -97,7 +96,7 @@ module Homebrew
fetched_bottle = false fetched_bottle = false
onoe e.message onoe e.message
opoo "Bottle fetch failed: fetching the source." opoo "Bottle fetch failed, fetching the source instead."
else else
fetched_bottle = true fetched_bottle = true
end end
@ -150,8 +149,8 @@ module Homebrew
def fetch_patch(p, args:) def fetch_patch(p, args:)
fetch_fetchable p, args: args fetch_fetchable p, args: args
rescue ChecksumMismatchError => e rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Patch reports different sha256: #{e.expected}" opoo "Patch reports different sha256: #{e.expected}"
Homebrew.failed = true
end end
def retry_fetch?(f, args:) def retry_fetch?(f, args:)

View File

@ -103,7 +103,7 @@ module Homebrew
logs[file.basename.to_s] = { content: contents } logs[file.basename.to_s] = { content: contents }
end end
end end
raise "No logs." if logs.empty? odie "No logs." if logs.empty?
logs logs
end end

View File

@ -20,6 +20,7 @@ module Homebrew
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
named_args [:formula, :cask] named_args [:formula, :cask]

View File

@ -58,14 +58,13 @@ module Homebrew
description: "Print JSON of all available formulae." description: "Print JSON of all available formulae."
switch "-v", "--verbose", switch "-v", "--verbose",
description: "Show more verbose analytics data for <formula>." description: "Show more verbose analytics data for <formula>."
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask"
conflicts "--installed", "--all" conflicts "--installed", "--all"
conflicts "--formula", "--cask"
named_args [:formula, :cask] named_args [:formula, :cask]
end end

View File

@ -146,7 +146,7 @@ module Homebrew
if args.ignore_dependencies? if args.ignore_dependencies?
opoo <<~EOS opoo <<~EOS
#{Tty.bold}--ignore-dependencies is an unsupported Homebrew developer flag!#{Tty.reset} #{Tty.bold}`--ignore-dependencies` is an unsupported Homebrew developer flag!#{Tty.reset}
Adjust your PATH to put any preferred versions of applications earlier in the Adjust your PATH to put any preferred versions of applications earlier in the
PATH rather than using this unsupported flag! PATH rather than using this unsupported flag!
@ -183,14 +183,15 @@ module Homebrew
formulae.each do |f| formulae.each do |f|
# head-only without --HEAD is an error # head-only without --HEAD is an error
if !args.HEAD? && f.stable.nil? if !args.HEAD? && f.stable.nil?
raise <<~EOS odie <<~EOS
#{f.full_name} is a head-only formula #{f.full_name} is a head-only formula.
Install with `brew install --HEAD #{f.full_name}` To install it, run:
brew install --HEAD #{f.full_name}
EOS EOS
end end
# --HEAD, fail with no head defined # --HEAD, fail with no head defined
raise "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil? odie "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil?
installed_head_version = f.latest_head_version installed_head_version = f.latest_head_version
if installed_head_version && if installed_head_version &&
@ -207,15 +208,17 @@ module Homebrew
if f.outdated? if f.outdated?
optlinked_version = Keg.for(f.opt_prefix).version optlinked_version = Keg.for(f.opt_prefix).version
onoe <<~EOS onoe <<~EOS
#{f.full_name} #{optlinked_version} is already installed #{f.full_name} #{optlinked_version} is already installed.
To upgrade to #{f.version}, run `brew upgrade #{f.full_name}` To upgrade to #{f.version}, run:
brew upgrade #{f.full_name}
EOS EOS
elsif args.only_dependencies? elsif args.only_dependencies?
installed_formulae << f installed_formulae << f
elsif !args.quiet? elsif !args.quiet?
opoo <<~EOS opoo <<~EOS
#{f.full_name} #{f.pkg_version} is already installed and up-to-date #{f.full_name} #{f.pkg_version} is already installed and up-to-date.
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}` To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS EOS
end end
elsif (args.HEAD? && new_head_installed) || prefix_installed elsif (args.HEAD? && new_head_installed) || prefix_installed
@ -236,14 +239,15 @@ module Homebrew
nil nil
else else
<<~EOS <<~EOS
#{msg} #{msg}.
The currently linked version is #{f.linked_version} The currently linked version is: #{f.linked_version}
EOS EOS
end end
elsif !f.linked? || f.keg_only? elsif !f.linked? || f.keg_only?
msg = <<~EOS msg = <<~EOS
#{msg}, it's just not linked #{msg}, it's just not linked.
You can use `brew link #{f}` to link this version. To link this version, run:
brew link #{f}
EOS EOS
elsif args.only_dependencies? elsif args.only_dependencies?
msg = nil msg = nil
@ -253,30 +257,36 @@ module Homebrew
nil nil
else else
<<~EOS <<~EOS
#{msg} and up-to-date #{msg} and up-to-date.
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}` To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS EOS
end end
end end
opoo msg if msg opoo msg if msg
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
msg = "#{old_formula.full_name} #{old_formula.any_installed_version} already installed" msg = "#{old_formula.full_name} #{old_formula.any_installed_version} already installed"
if !old_formula.linked? && !old_formula.keg_only? msg = if !old_formula.linked? && !old_formula.keg_only?
msg = <<~EOS <<~EOS
#{msg}, it's just not linked. #{msg}, it's just not linked.
You can use `brew link #{old_formula.full_name}` to link this version. To link this version, run:
brew link #{old_formula.full_name}
EOS EOS
elsif args.quiet? elsif args.quiet?
msg = nil nil
else
"#{msg}."
end end
opoo msg if msg opoo msg if msg
elsif f.migration_needed? && !args.force? elsif f.migration_needed? && !args.force?
# Check if the formula we try to install is the same as installed # Check if the formula we try to install is the same as installed
# but not migrated one. If --force is passed then install anyway. # but not migrated one. If --force is passed then install anyway.
opoo <<~EOS opoo <<~EOS
#{f.oldname} is already installed, it's just not migrated #{f.oldname} is already installed, it's just not migrated.
You can migrate this formula with `brew migrate #{f}` To migrate this formula, run:
Or you can force install it with `brew install #{f} --force` brew migrate #{f}
Or to force-install it, run:
brew install #{f} --force
EOS EOS
else else
# If none of the above is true and the formula is linked, then # If none of the above is true and the formula is linked, then

View File

@ -86,7 +86,7 @@ module Homebrew
end end
if !args.force? && (formula.blank? || !formula.keg_only_reason.versioned_formula?) if !args.force? && (formula.blank? || !formula.keg_only_reason.versioned_formula?)
opoo "#{keg.name} is keg-only and must be linked with --force" opoo "#{keg.name} is keg-only and must be linked with `--force`."
puts_keg_only_path_message(keg) puts_keg_only_path_message(keg)
next next
end end
@ -104,7 +104,7 @@ module Homebrew
puts puts
raise raise
else else
puts "#{n} symlinks created" puts "#{n} symlinks created."
end end
puts_keg_only_path_message(keg) if keg_only && !Homebrew::EnvConfig.developer? puts_keg_only_path_message(keg) if keg_only && !Homebrew::EnvConfig.developer?

View File

@ -65,7 +65,7 @@ module Homebrew
if File.exist? "#{repo}/.git/shallow" if File.exist? "#{repo}/.git/shallow"
opoo <<~EOS opoo <<~EOS
#{name} is a shallow clone so only partial output will be shown. #{name} is a shallow clone so only partial output will be shown.
To get a full clone run: To get a full clone, run:
git -C "#{git_cd}" fetch --unshallow git -C "#{git_cd}" fetch --unshallow
EOS EOS
end end

View File

@ -31,7 +31,8 @@ module Homebrew
if f.oldname if f.oldname
rack = HOMEBREW_CELLAR/f.oldname rack = HOMEBREW_CELLAR/f.oldname
raise NoSuchKegError, f.oldname if !rack.exist? || rack.subdirs.empty? raise NoSuchKegError, f.oldname if !rack.exist? || rack.subdirs.empty?
raise "#{rack} is a symlink" if rack.symlink?
odie "#{rack} is a symlink" if rack.symlink?
end end
migrator = Migrator.new(f, force: args.force?) migrator = Migrator.new(f, force: args.force?)

View File

@ -28,9 +28,9 @@ module Homebrew
switch "--cask", switch "--cask",
description: "List only outdated casks." description: "List only outdated casks."
flag "--json", flag "--json",
description: "Print output in JSON format. There are two versions: v1 and v2. " \ description: "Print output in JSON format. There are two versions: `v1` and `v2`. " \
"v1 is deprecated and is currently the default if no version is specified. " \ "`v1` is deprecated and is currently the default if no version is specified. " \
"v2 prints outdated formulae and casks. " "`v2` prints outdated formulae and casks. "
switch "--fetch-HEAD", switch "--fetch-HEAD",
description: "Fetch the upstream repository to detect if the HEAD installation of the "\ description: "Fetch the upstream repository to detect if the HEAD installation of the "\
"formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\
@ -50,7 +50,7 @@ module Homebrew
case (j = json_version(args.json)) case (j = json_version(args.json))
when :v1 when :v1
odisabled "brew outdated --json#{j == :v1 ? "=v1" : ""}", "brew outdated --json=v2" odisabled "`brew outdated --json#{j == :v1 ? "=v1" : ""}`", "`brew outdated --json=v2`"
when :v2, :default when :v2, :default
formulae, casks = if args.formula? formulae, casks = if args.formula?
[outdated_formulae(args: args), []] [outdated_formulae(args: args), []]

View File

@ -51,18 +51,18 @@ module Homebrew
description: "Search for GitHub pull requests containing <text>." description: "Search for GitHub pull requests containing <text>."
switch "--open", switch "--open",
depends_on: "--pull-request", depends_on: "--pull-request",
description: "Search for only open GitHub pull requests" description: "Search for only open GitHub pull requests."
switch "--closed", switch "--closed",
depends_on: "--pull-request", depends_on: "--pull-request",
description: "Search for only closed GitHub pull requests" description: "Search for only closed GitHub pull requests."
conflicts "--open", "--closed"
package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" } package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" }
package_manager_switches.each do |s| package_manager_switches.each do |s|
switch s, switch s,
description: "Search for <text> in the given package manager's list." description: "Search for <text> in the given package manager's list."
end end
conflicts("--desc", "--pull-request") conflicts "--desc", "--pull-request"
conflicts "--open", "--closed"
conflicts(*package_manager_switches) conflicts(*package_manager_switches)
# TODO: (2.9) add `min: 1` when the `odeprecated`/`odisabled` for `brew search` with no arguments is removed # TODO: (2.9) add `min: 1` when the `odeprecated`/`odisabled` for `brew search` with no arguments is removed
@ -85,7 +85,7 @@ module Homebrew
puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort) puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort)
else else
odeprecated "'brew search' with no arguments to output formulae", "'brew formulae'" odeprecated "`brew search` with no arguments to output formulae", "`brew formulae`"
puts Formatter.columns(Formula.full_names.sort) puts Formatter.columns(Formula.full_names.sort)
end end
@ -119,15 +119,11 @@ module Homebrew
print_casks = args.cask? print_casks = args.cask?
print_formulae = print_casks = true if !print_formulae && !print_casks print_formulae = print_casks = true if !print_formulae && !print_casks
if print_formulae && all_formulae.any? ohai "Formulae", Formatter.columns(all_formulae) if print_formulae && all_formulae.any?
ohai "Formulae"
puts Formatter.columns(all_formulae)
end
if print_casks && all_casks.any? if print_casks && all_casks.any?
puts if args.formula? && all_formulae.any? puts if args.formula? && all_formulae.any?
ohai "Casks" ohai "Casks", Formatter.columns(all_casks)
puts Formatter.columns(all_casks)
end end
count = all_formulae.count + all_casks.count count = all_formulae.count + all_casks.count
@ -140,7 +136,7 @@ module Homebrew
puts reason puts reason
end end
raise "No formulae or casks found for #{query.inspect}." if count.zero? odie "No formulae or casks found for #{query.inspect}." if count.zero?
end end
return unless $stdout.tty? return unless $stdout.tty?

View File

@ -27,16 +27,16 @@ module Homebrew
switch "--zap", switch "--zap",
description: "Remove all files associated with a <cask>. " \ description: "Remove all files associated with a <cask>. " \
"*May remove files which are shared between applications.*" "*May remove files which are shared between applications.*"
conflicts "--formula", "--zap"
switch "--ignore-dependencies", switch "--ignore-dependencies",
description: "Don't fail uninstall, even if <formula> is a dependency of any installed "\ description: "Don't fail uninstall, even if <formula> is a dependency of any installed "\
"formulae." "formulae."
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
conflicts "--formula", "--zap"
named_args [:installed_formula, :installed_cask], min: 1 named_args [:installed_formula, :installed_cask], min: 1
end end

View File

@ -54,7 +54,7 @@ module Homebrew
puts <<~EOS puts <<~EOS
#{Tty.bold}Read the analytics documentation (and how to opt-out) here: #{Tty.bold}Read the analytics documentation (and how to opt-out) here:
#{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}
No analytics have been recorded yet (or will be during this `brew` run). No analytics have been recorded yet (nor will be during this `brew` run).
EOS EOS
@ -343,7 +343,7 @@ class Reporter
new_tap = Tap.fetch(new_tap_name) new_tap = Tap.fetch(new_tap_name)
new_tap.install unless new_tap.installed? new_tap.install unless new_tap.installed?
ohai "#{name} has been moved to Homebrew.", <<~EOS ohai "#{name} has been moved to Homebrew.", <<~EOS
To uninstall the cask run: To uninstall the cask, run:
brew uninstall --cask --force #{name} brew uninstall --cask --force #{name}
EOS EOS
next if (HOMEBREW_CELLAR/new_name.split("/").last).directory? next if (HOMEBREW_CELLAR/new_name.split("/").last).directory?
@ -384,7 +384,7 @@ class Reporter
EOS EOS
else else
ohai "#{name} has been moved to Homebrew Cask.", <<~EOS ohai "#{name} has been moved to Homebrew Cask.", <<~EOS
To uninstall the formula and install the cask run: To uninstall the formula and install the cask, run:
brew uninstall --force #{name} brew uninstall --force #{name}
brew tap #{new_tap_name} brew tap #{new_tap_name}
brew install --cask #{new_name} brew install --cask #{new_name}
@ -470,10 +470,7 @@ class ReporterHub
dump_formula_report :M, "Updated Formulae" dump_formula_report :M, "Updated Formulae"
else else
updated = select_formula(:M).count updated = select_formula(:M).count
if updated.positive? ohai "Updated Formulae", "Updated #{updated} #{"formula".pluralize(updated)}." if updated.positive?
ohai "Updated Formulae"
puts "Updated #{updated} #{"formula".pluralize(updated)}."
end
end end
dump_formula_report :R, "Renamed Formulae" dump_formula_report :R, "Renamed Formulae"
dump_formula_report :D, "Deleted Formulae" dump_formula_report :D, "Deleted Formulae"
@ -482,10 +479,7 @@ class ReporterHub
dump_formula_report :MC, "Updated Casks" dump_formula_report :MC, "Updated Casks"
else else
updated = select_formula(:MC).count updated = select_formula(:MC).count
if updated.positive? ohai "Updated Casks", "Updated #{updated} #{"cask".pluralize(updated)}." if updated.positive?
ohai "Updated Casks"
puts "Updated #{updated} #{"cask".pluralize(updated)}."
end
end end
dump_formula_report :DC, "Deleted Casks" dump_formula_report :DC, "Deleted Casks"
end end
@ -525,8 +519,7 @@ class ReporterHub
return if formulae.empty? return if formulae.empty?
# Dump formula list. # Dump formula list.
ohai title ohai title, Formatter.columns(formulae.sort)
puts Formatter.columns(formulae.sort)
end end
def installed?(formula) def installed?(formula)

View File

@ -114,8 +114,8 @@ pop_stash() {
pop_stash_message() { pop_stash_message() {
[[ -z "$STASHED" ]] && return [[ -z "$STASHED" ]] && return
echo "To restore the stashed changes to $DIR run:" echo "To restore the stashed changes to $DIR, run:"
echo " 'cd $DIR && git stash pop'" echo " cd $DIR && git stash pop"
unset STASHED unset STASHED
} }
@ -370,7 +370,7 @@ EOS
# we cannot install a Homebrew cURL if homebrew/core is unavailable. # we cannot install a Homebrew cURL if homebrew/core is unavailable.
if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install curl if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install curl
then then
odie "Curl must be installed and in your PATH!" odie "'curl' must be installed and in your PATH!"
fi fi
fi fi
@ -381,7 +381,7 @@ EOS
# we cannot install a Homebrew Git if homebrew/core is unavailable. # we cannot install a Homebrew Git if homebrew/core is unavailable.
if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install git if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install git
then then
odie "Git must be installed and in your PATH!" odie "'git' must be installed and in your PATH!"
fi fi
fi fi

View File

@ -133,7 +133,7 @@ fetch() {
odie <<EOS odie <<EOS
Failed to download $VENDOR_URL and $VENDOR_URL2! Failed to download $VENDOR_URL and $VENDOR_URL2!
Do not file an issue on GitHub about this: you will need to figure out for Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to yourself what issue with your internet connection restricts your access to
both Bintray (used for Homebrew bottles/binary packages) and GitHub both Bintray (used for Homebrew bottles/binary packages) and GitHub
(used for Homebrew updates). (used for Homebrew updates).

View File

@ -56,7 +56,7 @@ HOMEBREW_CELLAR = Pathname(EnvVar["HOMEBREW_CELLAR"]).freeze
# Where downloads (bottles, source tarballs, etc.) are cached # Where downloads (bottles, source tarballs, etc.) are cached
HOMEBREW_CACHE = Pathname(EnvVar["HOMEBREW_CACHE"]).freeze HOMEBREW_CACHE = Pathname(EnvVar["HOMEBREW_CACHE"]).freeze
# Where brews installed via URL are cached # Where formulae installed via URL are cached
HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
# Where build, postinstall, and test logs of formulae are written to # Where build, postinstall, and test logs of formulae are written to

View File

@ -43,6 +43,10 @@ module Homebrew
description: "Run various additional style checks to determine if a new formula or cask is eligible "\ description: "Run various additional style checks to determine if a new formula or cask is eligible "\
"for Homebrew. This should be used when creating new formula and implies "\ "for Homebrew. This should be used when creating new formula and implies "\
"`--strict` and `--online`." "`--strict` and `--online`."
switch "--[no-]appcast",
description: "Audit the appcast."
switch "--token-conflicts",
description: "Audit for token conflicts."
flag "--tap=", flag "--tap=",
description: "Check the formulae within the given tap, specified as <user>`/`<repo>." description: "Check the formulae within the given tap, specified as <user>`/`<repo>."
switch "--fix", switch "--fix",
@ -69,25 +73,18 @@ module Homebrew
comma_array "--except-cops", comma_array "--except-cops",
description: "Specify a comma-separated <cops> list to skip checking for violations of the listed "\ description: "Specify a comma-separated <cops> list to skip checking for violations of the listed "\
"RuboCop cops." "RuboCop cops."
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
switch "--[no-]appcast",
description: "Audit the appcast"
switch "--token-conflicts",
description: "Audit for token conflicts"
conflicts "--formula", "--cask"
conflicts "--only", "--except" conflicts "--only", "--except"
conflicts "--only-cops", "--except-cops", "--strict" conflicts "--only-cops", "--except-cops", "--strict"
conflicts "--only-cops", "--except-cops", "--only" conflicts "--only-cops", "--except-cops", "--only"
conflicts "--display-cop-names", "--skip-style" conflicts "--display-cop-names", "--skip-style"
conflicts "--display-cop-names", "--only-cops" conflicts "--display-cop-names", "--only-cops"
conflicts "--display-cop-names", "--except-cops" conflicts "--display-cop-names", "--except-cops"
conflicts "--formula", "--cask"
named_args [:formula, :cask] named_args [:formula, :cask]
end end

View File

@ -400,7 +400,7 @@ module Homebrew
end end
odie <<~EOS odie <<~EOS
--keep-old was passed but there are changes in: `--keep-old` was passed but there are changes in:
#{mismatches.join("\n")} #{mismatches.join("\n")}
EOS EOS
end end
@ -566,7 +566,7 @@ module Homebrew
def old_checksums(formula, formula_ast, bottle_hash, args:) def old_checksums(formula, formula_ast, bottle_hash, args:)
bottle_node = formula_ast.bottle_block bottle_node = formula_ast.bottle_block
if bottle_node.nil? if bottle_node.nil?
odie "--keep-old was passed but there was no existing bottle block!" if args.keep_old? odie "`--keep-old` was passed but there was no existing bottle block!" if args.keep_old?
return return
end end
return [] unless args.keep_old? return [] unless args.keep_old?
@ -576,7 +576,7 @@ module Homebrew
mismatches, checksums = merge_bottle_spec(old_keys, old_bottle_spec, bottle_hash["bottle"]) mismatches, checksums = merge_bottle_spec(old_keys, old_bottle_spec, bottle_hash["bottle"])
if mismatches.present? if mismatches.present?
odie <<~EOS odie <<~EOS
--keep-old was passed but there are changes in: `--keep-old` was passed but there are changes in:
#{mismatches.join("\n")} #{mismatches.join("\n")}
EOS EOS
end end

View File

@ -113,7 +113,7 @@ module Homebrew
if new_version.present? if new_version.present?
if new_version.latest? if new_version.latest?
opoo "Ignoring specified --sha256= argument." if new_hash.present? opoo "Ignoring specified `--sha256=` argument." if new_hash.present?
new_hash = :no_check new_hash = :no_check
elsif new_hash.nil? || cask.languages.present? elsif new_hash.nil? || cask.languages.present?
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path, tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,

View File

@ -110,7 +110,7 @@ module Homebrew
ohai "Fetching remote #{homebrew_core_remote}" ohai "Fetching remote #{homebrew_core_remote}"
safe_system "git", "fetch", homebrew_core_remote, "HEAD", default_origin_branch safe_system "git", "fetch", homebrew_core_remote, "HEAD", default_origin_branch
if quiet_system "git", "cat-file", "-e", "#{full_origin_branch}:#{formula_path}" if quiet_system "git", "cat-file", "-e", "#{full_origin_branch}:#{formula_path}"
ohai "#{formula.full_name} exists in #{full_origin_branch}" ohai "#{formula.full_name} exists in #{full_origin_branch}."
safe_system "git", "checkout", full_origin_branch safe_system "git", "checkout", full_origin_branch
return tap_full_name, homebrew_core_remote, default_origin_branch, previous_branch return tap_full_name, homebrew_core_remote, default_origin_branch, previous_branch
end end
@ -196,7 +196,7 @@ module Homebrew
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD") new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
new_revision = new_revision.strip new_revision = new_revision.strip
elsif new_revision.blank? elsif new_revision.blank?
odie "#{formula}: the current URL requires specifying a --revision= argument." odie "#{formula}: the current URL requires specifying a `--revision=` argument."
end end
false false
elsif new_url.blank? && new_version.blank? elsif new_url.blank? && new_version.blank?
@ -351,7 +351,7 @@ module Homebrew
alias_rename = alias_update_pair(formula, new_formula_version) alias_rename = alias_update_pair(formula, new_formula_version)
if alias_rename.present? if alias_rename.present?
ohai "renaming alias #{alias_rename.first} to #{alias_rename.last}" ohai "Renaming alias #{alias_rename.first} to #{alias_rename.last}"
alias_rename.map! { |a| formula.tap.alias_dir/a } alias_rename.map! { |a| formula.tap.alias_dir/a }
end end
@ -424,11 +424,11 @@ module Homebrew
return if new_mirrors.present? || old_mirrors.empty? return if new_mirrors.present? || old_mirrors.empty?
if args.force? if args.force?
opoo "#{formula}: Removing all mirrors because a --mirror= argument was not specified." opoo "#{formula}: Removing all mirrors because a `--mirror=` argument was not specified."
else else
odie <<~EOS odie <<~EOS
#{formula}: a --mirror= argument for updating the mirror URL(s) was not specified. #{formula}: a `--mirror=` argument for updating the mirror URL(s) was not specified.
Use --force to remove all mirrors. Use `--force` to remove all mirrors.
EOS EOS
end end
end end
@ -439,7 +439,7 @@ module Homebrew
resource.owner = Resource.new(formula.name) resource.owner = Resource.new(formula.name)
forced_version = new_version && new_version != resource.version forced_version = new_version && new_version != resource.version
resource.version = new_version if forced_version resource.version = new_version if forced_version
odie "No --version= argument specified!" if resource.version.blank? odie "No `--version=` argument specified!" if resource.version.blank?
[resource.fetch, forced_version] [resource.fetch, forced_version]
end end

View File

@ -116,9 +116,11 @@ module Homebrew
end end
ohai title ohai title
puts "Current formula version: #{current_version}" puts <<~EOS
puts "Latest Repology version: #{repology_latest}" Current formula version: #{current_version}
puts "Latest livecheck version: #{livecheck_latest}" Latest Repology version: #{repology_latest}
puts "Open pull requests: #{pull_requests}" Latest livecheck version: #{livecheck_latest}
Open pull requests: #{pull_requests}
EOS
end end
end end

View File

@ -19,6 +19,7 @@ module Homebrew
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
named_args [:formula, :cask], number: 1 named_args [:formula, :cask], number: 1

View File

@ -145,7 +145,7 @@ module Homebrew
fc.tap = Tap.fetch(args.tap || "homebrew/core") fc.tap = Tap.fetch(args.tap || "homebrew/core")
raise TapUnavailableError, args.tap unless fc.tap.installed? raise TapUnavailableError, args.tap unless fc.tap.installed?
fc.url = args.named.first # Pull the first (and only) url from ARGV fc.url = args.named.first # Pull the first (and only) URL from ARGV
fc.mode = if args.autotools? fc.mode = if args.autotools?
:autotools :autotools
@ -180,7 +180,7 @@ module Homebrew
# unless --force is specified. # unless --force is specified.
unless args.force? unless args.force?
if reason = MissingFormula.disallowed_reason(fc.name) if reason = MissingFormula.disallowed_reason(fc.name)
raise <<~EOS odie <<~EOS
The formula '#{fc.name}' is not allowed to be created. The formula '#{fc.name}' is not allowed to be created.
#{reason} #{reason}
If you really want to create this formula use `--force`. If you really want to create this formula use `--force`.
@ -189,7 +189,7 @@ module Homebrew
if Formula.aliases.include? fc.name if Formula.aliases.include? fc.name
realname = Formulary.canonical_name(fc.name) realname = Formulary.canonical_name(fc.name)
raise <<~EOS odie <<~EOS
The formula '#{realname}' is already aliased to '#{fc.name}'. The formula '#{realname}' is already aliased to '#{fc.name}'.
Please check that you are not creating a duplicate. Please check that you are not creating a duplicate.
To force creation use `--force`. To force creation use `--force`.

View File

@ -21,6 +21,7 @@ module Homebrew
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
named_args [:formula, :cask] named_args [:formula, :cask]
@ -32,7 +33,7 @@ module Homebrew
args = edit_args.parse args = edit_args.parse
unless (HOMEBREW_REPOSITORY/".git").directory? unless (HOMEBREW_REPOSITORY/".git").directory?
raise <<~EOS odie <<~EOS
Changes will be lost! Changes will be lost!
The first time you `brew update`, all local changes will be lost; you should The first time you `brew update`, all local changes will be lost; you should
thus `brew update` before you `brew edit`! thus `brew update` before you `brew edit`!
@ -44,10 +45,10 @@ module Homebrew
raise UsageError, "#{path} doesn't exist on disk. " \ raise UsageError, "#{path} doesn't exist on disk. " \
"Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \ "Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \
"to create a new Formula!" "to create a new formula!"
end.presence end.presence
# If no brews are listed, open the project root in an editor. # If no formulae are listed, open the project root in an editor.
paths ||= [HOMEBREW_REPOSITORY] paths ||= [HOMEBREW_REPOSITORY]
exec_editor(*paths) exec_editor(*paths)

View File

@ -214,8 +214,7 @@ module Homebrew
odebug "Overwriting existing formula at #{path}" odebug "Overwriting existing formula at #{path}"
path.delete path.delete
end end
ohai "Writing formula for #{name} from revision #{rev} to:" ohai "Writing formula for #{name} from revision #{rev} to:", path
puts path
path.write result path.write result
end end

View File

@ -40,10 +40,12 @@ module Homebrew
args = irb_args.parse(ARGV.dup.freeze) args = irb_args.parse(ARGV.dup.freeze)
if args.examples? if args.examples?
puts "'v8'.f # => instance of the v8 formula" puts <<~EOS
puts ":hub.f.latest_version_installed?" 'v8'.f # => instance of the v8 formula
puts ":lua.f.methods - 1.methods" :hub.f.latest_version_installed?
puts ":mpd.f.recursive_dependencies.reject(&:installed?)" :lua.f.methods - 1.methods
:mpd.f.recursive_dependencies.reject(&:installed?)
EOS
return return
end end
@ -59,8 +61,7 @@ module Homebrew
require "keg" require "keg"
require "cask" require "cask"
ohai "Interactive Homebrew Shell" ohai "Interactive Homebrew Shell", "Example commands available with: `brew irb --examples`"
puts "Example commands available with: brew irb --examples"
if args.pry? if args.pry?
Pry.start Pry.start
else else

View File

@ -44,6 +44,7 @@ module Homebrew
description: "Only check formulae." description: "Only check formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Only check casks." description: "Only check casks."
conflicts "--debug", "--json" conflicts "--debug", "--json"
conflicts "--tap=", "--all", "--installed" conflicts "--tap=", "--all", "--installed"
conflicts "--cask", "--formula" conflicts "--cask", "--formula"

View File

@ -22,7 +22,7 @@ module Homebrew
description <<~EOS description <<~EOS
Generate Homebrew's manpages. Generate Homebrew's manpages.
Not (yet) working on Apple Silicon. *Note:* Not (yet) working on Apple Silicon.
EOS EOS
switch "--fail-if-changed", switch "--fail-if-changed",
description: "Return a failing status code if changes are detected in the manpage outputs. This "\ description: "Return a failing status code if changes are detected in the manpage outputs. This "\

View File

@ -49,7 +49,7 @@ module Homebrew
_, user, repo, issue = *url_match _, user, repo, issue = *url_match
odie "Not a GitHub pull request: #{arg}" unless issue odie "Not a GitHub pull request: #{arg}" unless issue
if args.tap.present? && !"#{user}/#{repo}".casecmp(tap.full_name).zero? if args.tap.present? && !"#{user}/#{repo}".casecmp(tap.full_name).zero?
odie "Pull request URL is for #{user}/#{repo} but --tap=#{tap.full_name}!" odie "Pull request URL is for #{user}/#{repo} but `--tap=#{tap.full_name}` was specified!"
end end
ohai "Dispatching #{tap} pull request ##{issue}" ohai "Dispatching #{tap} pull request ##{issue}"

View File

@ -340,7 +340,7 @@ module Homebrew
end end
def download_artifact(url, dir, pr) def download_artifact(url, dir, pr)
raise "Credentials must be set to access the Artifacts API" if GitHub.api_credentials_type == :none odie "Credentials must be set to access the Artifacts API" if GitHub.api_credentials_type == :none
token = GitHub.api_credentials token = GitHub.api_credentials
curl_args = ["--header", "Authorization: token #{token}"] curl_args = ["--header", "Authorization: token #{token}"]
@ -414,7 +414,7 @@ module Homebrew
workflow_run.first.blank? workflow_run.first.blank?
# Ignore that workflow as it was not executed and we specified # Ignore that workflow as it was not executed and we specified
# that we could skip it. # that we could skip it.
ohai "Ignoring workflow #{workflow} as requested by --ignore-missing-artifacts" ohai "Ignoring workflow #{workflow} as requested by `--ignore-missing-artifacts`"
next next
end end

View File

@ -81,8 +81,11 @@ module Homebrew
else else
"Bintray" "Bintray"
end end
puts "brew #{bottle_args.join " "}" puts <<~EOS
puts "Upload bottles described by these JSON files to #{service}:\n #{json_files.join("\n ")}" brew #{bottle_args.join " "}
Upload bottles described by these JSON files to #{service}:
#{json_files.join("\n ")}
EOS
return return
end end

View File

@ -37,7 +37,7 @@ module Homebrew
branch = args.branch || "main" branch = args.branch || "main"
tap = args.named.to_taps.first tap = args.named.to_taps.first
raise "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX) odie "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX)
titleized_user = tap.user.dup titleized_user = tap.user.dup
titleized_repo = tap.repo.dup titleized_repo = tap.repo.dup
@ -169,7 +169,7 @@ module Homebrew
def write_path(tap, filename, content) def write_path(tap, filename, content)
path = tap.path/filename path = tap.path/filename
tap.path.mkpath tap.path.mkpath
raise "#{path} already exists" if path.exist? odie "#{path} already exists" if path.exist?
path.write content path.write content
end end

View File

@ -23,8 +23,8 @@ module Homebrew
switch "--update", switch "--update",
description: "Update RBI files." description: "Update RBI files."
switch "--suggest-typed", switch "--suggest-typed",
description: "Try upgrading `typed` sigils.", depends_on: "--update",
depends_on: "--update" description: "Try upgrading `typed` sigils."
switch "--fail-if-not-changed", switch "--fail-if-not-changed",
description: "Return a failing status code if all gems are up to date " \ description: "Return a failing status code if all gems are up to date " \
"and gem definitions do not need a tapioca update." "and gem definitions do not need a tapioca update."

View File

@ -13,14 +13,15 @@ module Homebrew
def unbottled_args def unbottled_args
Homebrew::CLI::Parser.new do Homebrew::CLI::Parser.new do
description <<~EOS description <<~EOS
Outputs the unbottled dependents of formulae. Show the unbottled dependents of formulae.
EOS EOS
flag "--tag=", flag "--tag=",
description: "Use the specified bottle tag (e.g. big_sur) instead of the current OS." description: "Use the specified bottle tag (e.g. `big_sur`) instead of the current OS."
switch "--dependents", switch "--dependents",
description: "Don't get analytics data and sort by number of dependents instead." description: "Skip getting analytics data and sort by number of dependents instead."
switch "--total", switch "--total",
description: "Output the number of unbottled and total formulae." description: "Print the number of unbottled and total formulae."
conflicts "--dependents", "--total" conflicts "--dependents", "--total"
named_args :formula named_args :formula

View File

@ -45,13 +45,13 @@ module Homebrew
unpack_dir = Pathname.pwd unpack_dir = Pathname.pwd
end end
raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real? odie "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
formulae.each do |f| formulae.each do |f|
stage_dir = unpack_dir/"#{f.name}-#{f.version}" stage_dir = unpack_dir/"#{f.name}-#{f.version}"
if stage_dir.exist? if stage_dir.exist?
raise "Destination #{stage_dir} already exists!" unless args.force? odie "Destination #{stage_dir} already exists!" unless args.force?
rm_rf stage_dir rm_rf stage_dir
end end
@ -68,7 +68,7 @@ module Homebrew
next unless args.git? next unless args.git?
ohai "Setting up git repository" ohai "Setting up Git repository"
cd stage_dir cd stage_dir
system "git", "init", "-q" system "git", "init", "-q"
system "git", "add", "-A" system "git", "add", "-A"

View File

@ -95,8 +95,10 @@ module Homebrew
end end
end end
puts "Start commit: #{start_commit}" puts <<~EOS
puts " End commit: #{end_commit}" Start commit: #{start_commit}
End commit: #{end_commit}
EOS
mkdir "update-test" mkdir "update-test"
chdir "update-test" do chdir "update-test" do
@ -127,15 +129,15 @@ module Homebrew
quiet_system "brew", "help" quiet_system "brew", "help"
# run brew update # run brew update
oh1 "Running brew update..." oh1 "Running `brew update`..."
safe_system "brew", "update", "--verbose", "--debug" safe_system "brew", "update", "--verbose", "--debug"
actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp
if actual_end_commit != end_commit if actual_end_commit != end_commit
start_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", start_commit).chomp start_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", start_commit).chomp
end_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", end_commit).chomp end_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", end_commit).chomp
actual_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", actual_end_commit).chomp actual_log = Utils.popen_read("git", "log", "-1", "--decorate", "--oneline", actual_end_commit).chomp
raise <<~EOS odie <<~EOS
brew update didn't update #{branch}! `brew update` didn't update #{branch}!
Start commit: #{start_log} Start commit: #{start_log}
Expected end commit: #{end_log} Expected end commit: #{end_log}
Actual end commit: #{actual_log} Actual end commit: #{actual_log}

View File

@ -264,11 +264,11 @@ module Homebrew
] ]
__check_stray_files "/usr/local/lib/pkgconfig", "*.pc", allow_list, <<~EOS __check_stray_files "/usr/local/lib/pkgconfig", "*.pc", allow_list, <<~EOS
Unbrewed .pc files were found in /usr/local/lib/pkgconfig. Unbrewed '.pc' files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected .pc files: Unexpected '.pc' files:
EOS EOS
end end
@ -285,11 +285,11 @@ module Homebrew
] ]
__check_stray_files "/usr/local/lib", "*.la", allow_list, <<~EOS __check_stray_files "/usr/local/lib", "*.la", allow_list, <<~EOS
Unbrewed .la files were found in /usr/local/lib. Unbrewed '.la' files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected .la files: Unexpected '.la' files:
EOS EOS
end end
@ -335,7 +335,8 @@ module Homebrew
<<~EOS <<~EOS
#{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set. #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set.
Please execute `sudo chmod +t #{HOMEBREW_TEMP}` in your Terminal. To set it, run the following command:
sudo chmod +t #{HOMEBREW_TEMP}
EOS EOS
end end
alias generic_check_tmpdir_sticky_bit check_tmpdir_sticky_bit alias generic_check_tmpdir_sticky_bit check_tmpdir_sticky_bit
@ -350,7 +351,7 @@ module Homebrew
The following directories do not exist: The following directories do not exist:
#{not_exist_dirs.join("\n")} #{not_exist_dirs.join("\n")}
You should create these directories and change their ownership to your account. You should create these directories and change their ownership to your user.
sudo mkdir -p #{not_exist_dirs.join(" ")} sudo mkdir -p #{not_exist_dirs.join(" ")}
sudo chown -R $(whoami) #{not_exist_dirs.join(" ")} sudo chown -R $(whoami) #{not_exist_dirs.join(" ")}
EOS EOS
@ -404,7 +405,7 @@ module Homebrew
unless conflicts.empty? unless conflicts.empty?
message = inject_file_list conflicts, <<~EOS message = inject_file_list conflicts, <<~EOS
/usr/bin occurs before #{HOMEBREW_PREFIX}/bin /usr/bin occurs before #{HOMEBREW_PREFIX}/bin in your PATH.
This means that system-provided programs will be used instead of those This means that system-provided programs will be used instead of those
provided by Homebrew. Consider setting your PATH so that provided by Homebrew. Consider setting your PATH so that
#{HOMEBREW_PREFIX}/bin occurs before /usr/bin. Here is a one-liner: #{HOMEBREW_PREFIX}/bin occurs before /usr/bin. Here is a one-liner:
@ -428,8 +429,8 @@ module Homebrew
return if @seen_prefix_bin return if @seen_prefix_bin
<<~EOS <<~EOS
Homebrew's bin was not found in your PATH. Homebrew's "bin" was not found in your PATH.
Consider setting the PATH for example like so: Consider setting your PATH for example like so:
#{Utils::Shell.prepend_path_in_profile("#{HOMEBREW_PREFIX}/bin")} #{Utils::Shell.prepend_path_in_profile("#{HOMEBREW_PREFIX}/bin")}
EOS EOS
end end
@ -444,9 +445,9 @@ module Homebrew
return if sbin.children.one? && sbin.children.first.basename.to_s == ".keepme" return if sbin.children.one? && sbin.children.first.basename.to_s == ".keepme"
<<~EOS <<~EOS
Homebrew's sbin was not found in your PATH but you have installed Homebrew's "sbin" was not found in your PATH but you have installed
formulae that put executables in #{HOMEBREW_PREFIX}/sbin. formulae that put executables in #{HOMEBREW_PREFIX}/sbin.
Consider setting the PATH for example like so: Consider setting your PATH for example like so:
#{Utils::Shell.prepend_path_in_profile("#{HOMEBREW_PREFIX}/sbin")} #{Utils::Shell.prepend_path_in_profile("#{HOMEBREW_PREFIX}/sbin")}
EOS EOS
end end
@ -715,7 +716,7 @@ module Homebrew
return if (paths & gnubin).empty? return if (paths & gnubin).empty?
<<~EOS <<~EOS
Putting non-prefixed coreutils in your path can cause gmp builds to fail. Putting non-prefixed coreutils in your path can cause GMP builds to fail.
EOS EOS
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
@ -725,7 +726,7 @@ module Homebrew
return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg" return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg"
<<~EOS <<~EOS
A .pydistutils.cfg file was found in $HOME, which may cause Python A '.pydistutils.cfg' file was found in $HOME, which may cause Python
builds to fail. See: builds to fail. See:
#{Formatter.url("https://bugs.python.org/issue6138")} #{Formatter.url("https://bugs.python.org/issue6138")}
#{Formatter.url("https://bugs.python.org/issue4655")} #{Formatter.url("https://bugs.python.org/issue4655")}
@ -767,7 +768,7 @@ module Homebrew
inject_file_list unlinked, <<~EOS inject_file_list unlinked, <<~EOS
You have unlinked kegs in your Cellar. You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these: those kegs to fail to run properly once built. Run `brew link` on these:
EOS EOS
end end
@ -897,7 +898,8 @@ module Homebrew
<<~EOS <<~EOS
The staging path #{user_tilde(path.to_s)} is not writable by the current user. The staging path #{user_tilde(path.to_s)} is not writable by the current user.
To fix, run \'sudo chown -R $(whoami):staff #{user_tilde(path.to_s)}' To fix, run:
sudo chown -R $(whoami):staff #{user_tilde(path.to_s)}
EOS EOS
end end
@ -970,16 +972,18 @@ module Homebrew
if result.include? "Python 2.7" if result.include? "Python 2.7"
<<~EOS <<~EOS
Your Python installation has a broken version of setuptools. Your Python installation has a broken version of setuptools.
To fix, reinstall macOS or run 'sudo /usr/bin/python -m pip install -I setuptools'. To fix, reinstall macOS or run:
sudo /usr/bin/python -m pip install -I setuptools
EOS EOS
else else
<<~EOS <<~EOS
The system Python version is wrong. The system Python version is wrong.
To fix, run 'defaults write com.apple.versioner.python Version 2.7'. To fix, run:
defaults write com.apple.versioner.python Version 2.7
EOS EOS
end end
elsif result.stderr.include? "pkg_resources.DistributionNotFound" elsif result.stderr.include? "pkg_resources.DistributionNotFound"
"Your Python installation is unable to find xattr." "Your Python installation is unable to find `xattr`."
else else
"unknown xattr error: #{result.stderr.split("\n").last}" "unknown xattr error: #{result.stderr.split("\n").last}"
end end
@ -990,7 +994,7 @@ module Homebrew
when :quarantine_available when :quarantine_available
nil nil
when :xattr_broken when :xattr_broken
"There's not a working version of xattr." "There's no working version of `xattr` on this system."
when :no_swift when :no_swift
"Swift is not available on this system." "Swift is not available on this system."
when :no_quarantine when :no_quarantine

View File

@ -16,8 +16,8 @@ module Homebrew
default: "native", default: "native",
}, },
HOMEBREW_ARTIFACT_DOMAIN: { HOMEBREW_ARTIFACT_DOMAIN: {
description: "Prefix all download URLs, including those for bottles, with this " \ description: "Prefix all download URLs, including those for bottles, with this value. " \
"variable. For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a " \ "For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a " \
"formula with the URL `https://example.com/foo.tar.gz` to instead download from " \ "formula with the URL `https://example.com/foo.tar.gz` to instead download from " \
"`http://localhost:8080/example.com/foo.tar.gz`.", "`http://localhost:8080/example.com/foo.tar.gz`.",
}, },
@ -241,7 +241,7 @@ module Homebrew
HOMEBREW_NO_INSTALL_CLEANUP: { HOMEBREW_NO_INSTALL_CLEANUP: {
description: "If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically " \ description: "If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically " \
"cleanup installed/upgraded/reinstalled formulae or all formulae every " \ "cleanup installed/upgraded/reinstalled formulae or all formulae every " \
"HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS days.", "`HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS` days.",
boolean: true, boolean: true,
}, },
HOMEBREW_PRY: { HOMEBREW_PRY: {

View File

@ -384,8 +384,8 @@ class FormulaUnknownPythonError < RuntimeError
The version of Python to use with the virtualenv in the `#{formula.full_name}` formula The version of Python to use with the virtualenv in the `#{formula.full_name}` formula
cannot be guessed automatically because a recognised Python dependency could not be found. cannot be guessed automatically because a recognised Python dependency could not be found.
If you are using a non-standard Python depedency, please add `:using => "python@x.y"` to If you are using a non-standard Python dependency, please add `:using => "python@x.y"`
`virtualenv_install_with_resources` to resolve the issue manually. to 'virtualenv_install_with_resources' to resolve the issue manually.
EOS EOS
end end
end end
@ -394,10 +394,11 @@ end
class FormulaAmbiguousPythonError < RuntimeError class FormulaAmbiguousPythonError < RuntimeError
def initialize(formula) def initialize(formula)
super <<~EOS super <<~EOS
The version of python to use with the virtualenv in the `#{formula.full_name}` formula The version of Python to use with the virtualenv in the `#{formula.full_name}` formula
cannot be guessed automatically. If the simultaneous use of multiple pythons cannot be guessed automatically.
is intentional, please add `:using => "python@x.y"` to
`virtualenv_install_with_resources` to resolve the ambiguity manually. If the simultaneous use of multiple Pythons is intentional, please add `:using => "python@x.y"`
to 'virtualenv_install_with_resources' to resolve the ambiguity manually.
EOS EOS
end end
end end

View File

@ -276,14 +276,13 @@ module SharedEnvExtension
flags = [] flags = []
if fc if fc
ohai "Building with an alternative Fortran compiler" ohai "Building with an alternative Fortran compiler", "This is unsupported."
puts "This is unsupported."
self["F77"] ||= fc self["F77"] ||= fc
else else
if (gfortran = which("gfortran", (HOMEBREW_PREFIX/"bin").to_s)) if (gfortran = which("gfortran", (HOMEBREW_PREFIX/"bin").to_s))
ohai "Using Homebrew-provided Fortran compiler." ohai "Using Homebrew-provided Fortran compiler"
elsif (gfortran = which("gfortran", PATH.new(ORIGINAL_PATHS))) elsif (gfortran = which("gfortran", PATH.new(ORIGINAL_PATHS)))
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."

View File

@ -7,7 +7,7 @@ module OnOS
# # Do something Mac-specific # # Do something Mac-specific
# end</pre> # end</pre>
def on_macos(&block) def on_macos(&block)
raise "No block content defined for on_macos block" unless block raise "No block content defined for 'on_macos' block" unless block
end end
# Block only executed on Linux. No-op on macOS. # Block only executed on Linux. No-op on macOS.
@ -15,7 +15,7 @@ module OnOS
# # Do something Linux-specific # # Do something Linux-specific
# end</pre> # end</pre>
def on_linux(&block) def on_linux(&block)
raise "No block content defined for on_linux block" unless block raise "No block content defined for 'on_linux' block" unless block
end end
end end

View File

@ -3,7 +3,7 @@
module OnOS module OnOS
def on_linux(&block) def on_linux(&block)
raise "No block content defined for on_linux block" unless block raise "No block content defined for 'on_linux' block" unless block
yield yield
end end

View File

@ -3,7 +3,7 @@
module OnOS module OnOS
def on_macos(&block) def on_macos(&block)
raise "No block content defined for on_macos block" unless block raise "No block content defined for 'on_macos' block" unless block
yield yield
end end

View File

@ -100,13 +100,13 @@ class Pathname
src.resource.stage { install(*src.files) } src.resource.stage { install(*src.files) }
when Array when Array
if src.empty? if src.empty?
opoo "tried to install empty array to #{self}" opoo "Tried to install empty array to #{self}"
break break
end end
src.each { |s| install_p(s, File.basename(s)) } src.each { |s| install_p(s, File.basename(s)) }
when Hash when Hash
if src.empty? if src.empty?
opoo "tried to install empty hash to #{self}" opoo "Tried to install empty hash to #{self}"
break break
end end
src.each { |s, new_basename| install_p(s, new_basename) } src.each { |s, new_basename| install_p(s, new_basename) }
@ -372,7 +372,7 @@ class Pathname
def write_exec_script(*targets) def write_exec_script(*targets)
targets.flatten! targets.flatten!
if targets.empty? if targets.empty?
opoo "tried to write exec scripts to #{self} for an empty list of targets" opoo "Tried to write exec scripts to #{self} for an empty list of targets"
return return
end end
mkpath mkpath

View File

@ -828,7 +828,7 @@ class Formula
HOMEBREW_PREFIX/"var" HOMEBREW_PREFIX/"var"
end end
# The directory where the formula's ZSH function files should be # The directory where the formula's zsh function files should be
# installed. # installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with # This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only. # `brew link` for formulae that are not keg-only.
@ -852,7 +852,7 @@ class Formula
prefix/"etc/bash_completion.d" prefix/"etc/bash_completion.d"
end end
# The directory where the formula's ZSH completion files should be # The directory where the formula's zsh completion files should be
# installed. # installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with # This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only. # `brew link` for formulae that are not keg-only.
@ -1705,7 +1705,7 @@ class Formula
deps ||= declared_runtime_dependencies unless undeclared deps ||= declared_runtime_dependencies unless undeclared
deps ||= (declared_runtime_dependencies | undeclared_runtime_dependencies) deps ||= (declared_runtime_dependencies | undeclared_runtime_dependencies)
rescue FormulaUnavailableError rescue FormulaUnavailableError
onoe "could not get runtime dependencies from #{path}!" onoe "Could not get runtime dependencies from #{path}!"
deps ||= [] deps ||= []
end end
deps deps

View File

@ -221,13 +221,13 @@ module Homebrew
# Don't complain about missing cross-tap dependencies # Don't complain about missing cross-tap dependencies
next next
rescue FormulaUnavailableError rescue FormulaUnavailableError
problem "Can't find dependency #{dep.name.inspect}." problem "Can't find dependency '#{dep.name.inspect}'."
next next
rescue TapFormulaAmbiguityError rescue TapFormulaAmbiguityError
problem "Ambiguous dependency #{dep.name.inspect}." problem "Ambiguous dependency '#{dep.name.inspect}'."
next next
rescue TapFormulaWithOldnameAmbiguityError rescue TapFormulaWithOldnameAmbiguityError
problem "Ambiguous oldname dependency #{dep.name.inspect}." problem "Ambiguous oldname dependency '#{dep.name.inspect}'."
next next
end end
@ -258,10 +258,10 @@ module Homebrew
end end
end end
problem "Dependency #{dep} does not define option #{opt.name.inspect}" problem "Dependency '#{dep}' does not define option #{opt.name.inspect}"
end end
problem "Don't use git as a dependency (it's always available)" if @new_formula && dep.name == "git" problem "Don't use 'git' as a dependency (it's always available)" if @new_formula && dep.name == "git"
problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run) problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run)

View File

@ -19,7 +19,7 @@ module FormulaCellarChecks
return if ORIGINAL_PATHS.include? prefix_bin return if ORIGINAL_PATHS.include? prefix_bin
<<~EOS <<~EOS
#{prefix_bin} is not in your PATH "#{prefix_bin}" is not in your PATH.
You can amend this by altering your #{Utils::Shell.profile} file. You can amend this by altering your #{Utils::Shell.profile} file.
EOS EOS
end end
@ -29,9 +29,9 @@ module FormulaCellarChecks
return unless (formula.prefix/"man").directory? return unless (formula.prefix/"man").directory?
<<~EOS <<~EOS
A top-level "man" directory was found A top-level "man" directory was found.
Homebrew requires that man pages live under share. Homebrew requires that man pages live under "share".
This can often be fixed by passing "--mandir=\#{man}" to configure. This can often be fixed by passing `--mandir=\#{man}` to `configure`.
EOS EOS
end end
@ -40,9 +40,9 @@ module FormulaCellarChecks
return unless (formula.prefix/"info").directory? return unless (formula.prefix/"info").directory?
<<~EOS <<~EOS
A top-level "info" directory was found A top-level "info" directory was found.
Homebrew suggests that info pages live under share. Homebrew suggests that info pages live under "share".
This can often be fixed by passing "--infodir=\#{info}" to configure. This can often be fixed by passing `--infodir=\#{info}` to `configure`.
EOS EOS
end end
@ -53,11 +53,11 @@ module FormulaCellarChecks
return if jars.empty? return if jars.empty?
<<~EOS <<~EOS
JARs were installed to "#{formula.lib}" JARs were installed to "#{formula.lib}".
Installing JARs to "lib" can cause conflicts between packages. Installing JARs to "lib" can cause conflicts between packages.
For Java software, it is typically better for the formula to For Java software, it is typically better for the formula to
install to "libexec" and then symlink or wrap binaries into "bin". install to "libexec" and then symlink or wrap binaries into "bin".
See "activemq", "jruby", etc. for examples. See formulae 'activemq', 'jruby', etc. for examples.
The offending files are: The offending files are:
#{jars * "\n "} #{jars * "\n "}
EOS EOS
@ -81,7 +81,7 @@ module FormulaCellarChecks
return if non_libraries.empty? return if non_libraries.empty?
<<~EOS <<~EOS
Non-libraries were installed to "#{formula.lib}" Non-libraries were installed to "#{formula.lib}".
Installing non-libraries to "lib" is discouraged. Installing non-libraries to "lib" is discouraged.
The offending files are: The offending files are:
#{non_libraries * "\n "} #{non_libraries * "\n "}
@ -95,7 +95,7 @@ module FormulaCellarChecks
return if non_exes.empty? return if non_exes.empty?
<<~EOS <<~EOS
Non-executables were installed to "#{bin}" Non-executables were installed to "#{bin}".
The offending files are: The offending files are:
#{non_exes * "\n "} #{non_exes * "\n "}
EOS EOS
@ -109,11 +109,10 @@ module FormulaCellarChecks
return if generics.empty? return if generics.empty?
<<~EOS <<~EOS
Generic binaries were installed to "#{bin}" Generic binaries were installed to "#{bin}".
Binaries with generic names are likely to conflict with other software, Binaries with generic names are likely to conflict with other software.
and suggest that this software should be installed to "libexec" and then Homebrew suggests that this software is installed to "libexec" and then
symlinked as needed. symlinked as needed.
The offending files are: The offending files are:
#{generics * "\n "} #{generics * "\n "}
EOS EOS
@ -124,9 +123,9 @@ module FormulaCellarChecks
return if pth_found.empty? return if pth_found.empty?
<<~EOS <<~EOS
easy-install.pth files were found 'easy-install.pth' files were found.
These .pth files are likely to cause link conflicts. Please invoke These '.pth' files are likely to cause link conflicts.
setup.py using Language::Python.setup_install_args. Please invoke `setup.py` using 'Language::Python.setup_install_args'.
The offending files are: The offending files are:
#{pth_found * "\n "} #{pth_found * "\n "}
EOS EOS
@ -144,7 +143,7 @@ module FormulaCellarChecks
return unless bad_dir_name return unless bad_dir_name
<<~EOS <<~EOS
Emacs Lisp files were installed into the wrong site-lisp subdirectory. Emacs Lisp files were installed into the wrong "site-lisp" subdirectory.
They should be installed into: They should be installed into:
#{share}/emacs/site-lisp/#{name} #{share}/emacs/site-lisp/#{name}
EOS EOS
@ -161,11 +160,10 @@ module FormulaCellarChecks
return if elisps.empty? return if elisps.empty?
<<~EOS <<~EOS
Emacs Lisp files were linked directly to #{HOMEBREW_PREFIX}/share/emacs/site-lisp Emacs Lisp files were linked directly to "#{HOMEBREW_PREFIX}/share/emacs/site-lisp".
This may cause conflicts with other packages. This may cause conflicts with other packages.
They should instead be installed into: They should instead be installed into:
#{share}/emacs/site-lisp/#{name} #{share}/emacs/site-lisp/#{name}
The offending files are: The offending files are:
#{elisps * "\n "} #{elisps * "\n "}
EOS EOS
@ -251,7 +249,7 @@ module FormulaCellarChecks
Dir.chdir("/") do Dir.chdir("/") do
unless File.exist?(program_location) unless File.exist?(program_location)
return <<~EOS return <<~EOS
The plist #{key} does not exist: The plist "#{key}" does not exist:
#{program_location} #{program_location}
EOS EOS
end end
@ -260,7 +258,7 @@ module FormulaCellarChecks
end end
<<~EOS <<~EOS
The plist #{key} is not executable: The plist "#{key}" is not executable:
#{program_location} #{program_location}
EOS EOS
end end
@ -274,7 +272,7 @@ module FormulaCellarChecks
link.exist? && File.realpath(link).start_with?(HOMEBREW_CELLAR/name) link.exist? && File.realpath(link).start_with?(HOMEBREW_CELLAR/name)
end end
"Python formulae that are keg-only should not create `pip3` and `wheel3` symlinks" "Python formulae that are keg-only should not create `pip3` and `wheel3` symlinks."
end end
def audit_installed def audit_installed

View File

@ -362,14 +362,16 @@ class FormulaInstaller
EOS EOS
if formula.outdated? && !formula.head? if formula.outdated? && !formula.head?
message += <<~EOS message += <<~EOS
To upgrade to #{formula.pkg_version}, run `brew upgrade #{formula.full_name}`. To upgrade to #{formula.pkg_version}, run:
brew upgrade #{formula.full_name}
EOS EOS
elsif only_deps? elsif only_deps?
message = nil message = nil
else else
# some other version is already installed *and* linked # some other version is already installed *and* linked
message += <<~EOS message += <<~EOS
To install #{formula.pkg_version}, first run `brew unlink #{formula.name}`. To install #{formula.pkg_version}, first run:
brew unlink #{formula.name}
EOS EOS
end end
raise CannotInstallFormulaError, message if message raise CannotInstallFormulaError, message if message
@ -804,8 +806,9 @@ class FormulaInstaller
fix_dynamic_linkage(keg) if !@poured_bottle || !formula.bottle_specification.skip_relocation? fix_dynamic_linkage(keg) if !@poured_bottle || !formula.bottle_specification.skip_relocation?
if build_bottle? if build_bottle?
ohai "Not running post_install as we're building a bottle" ohai "Not running 'post_install' as we're building a bottle"
puts "You can run it manually using `brew postinstall #{formula.full_name}`" puts "You can run it manually using:"
puts " brew postinstall #{formula.full_name}"
else else
post_install post_install
end end
@ -951,10 +954,9 @@ class FormulaInstaller
begin begin
keg.optlink(verbose: verbose?) keg.optlink(verbose: verbose?)
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "Failed to create #{formula.opt_prefix}" ofail "Failed to create #{formula.opt_prefix}"
puts "Things that depend on #{formula.full_name} will probably not build." puts "Things that depend on #{formula.full_name} will probably not build."
puts e puts e
Homebrew.failed = true
end end
return return
end end
@ -991,25 +993,23 @@ class FormulaInstaller
link_overwrite_backup[conflict_file] = backup_file link_overwrite_backup[conflict_file] = backup_file
retry retry
end end
onoe "The `brew link` step did not complete successfully" ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts puts
puts "Possible conflicting files are:" puts "Possible conflicting files are:"
keg.link(dry_run: true, overwrite: true, verbose: verbose?) keg.link(dry_run: true, overwrite: true, verbose: verbose?)
@show_summary_heading = true @show_summary_heading = true
Homebrew.failed = true
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "The `brew link` step did not complete successfully" ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts puts
puts "You can try again using:" puts "You can try again using:"
puts " brew link #{formula.name}" puts " brew link #{formula.name}"
@show_summary_heading = true @show_summary_heading = true
Homebrew.failed = true
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "An unexpected error occurred during the `brew link` step" ofail "An unexpected error occurred during the `brew link` step"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts e.backtrace if debug? puts e.backtrace if debug?
@ -1021,16 +1021,15 @@ class FormulaInstaller
FileUtils.mv backup, origin FileUtils.mv backup, origin
end end
end end
Homebrew.failed = true
raise raise
end end
return if link_overwrite_backup.empty? return if link_overwrite_backup.empty?
opoo "These files were overwritten during `brew link` step:" opoo "These files were overwritten during the `brew link` step:"
puts link_overwrite_backup.keys puts link_overwrite_backup.keys
puts puts
puts "They have been backed up in #{backup_dir}" puts "They have been backed up to: #{backup_dir}"
@show_summary_heading = true @show_summary_heading = true
end end
@ -1043,20 +1042,18 @@ class FormulaInstaller
log = formula.var/"log" log = formula.var/"log"
log.mkpath if formula.plist.include? log.to_s log.mkpath if formula.plist.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Failed to install plist file" ofail "Failed to install plist file"
odebug e, e.backtrace odebug e, e.backtrace
Homebrew.failed = true
end end
sig { params(keg: Keg).void } sig { params(keg: Keg).void }
def fix_dynamic_linkage(keg) def fix_dynamic_linkage(keg)
keg.fix_dynamic_linkage keg.fix_dynamic_linkage
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Failed to fix install linkage" ofail "Failed to fix install linkage"
puts "The formula built, but you may encounter issues using it or linking other" puts "The formula built, but you may encounter issues using it or linking other"
puts "formulae against it." puts "formulae against it."
odebug e, e.backtrace odebug e, e.backtrace
Homebrew.failed = true
@show_summary_heading = true @show_summary_heading = true
end end
@ -1066,7 +1063,7 @@ class FormulaInstaller
Cleaner.new(formula).clean Cleaner.new(formula).clean
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The cleaning step did not complete successfully" opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix" puts "Still, the installation was successful, so we will link it into your prefix."
odebug e, e.backtrace odebug e, e.backtrace
Homebrew.failed = true Homebrew.failed = true
@show_summary_heading = true @show_summary_heading = true
@ -1103,7 +1100,8 @@ class FormulaInstaller
end end
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The post-install step did not complete successfully" opoo "The post-install step did not complete successfully"
puts "You can try again using `brew postinstall #{formula.full_name}`" puts "You can try again using:"
puts " brew postinstall #{formula.full_name}"
odebug e, e.backtrace, always_display: Homebrew::EnvConfig.developer? odebug e, e.backtrace, always_display: Homebrew::EnvConfig.developer?
Homebrew.failed = true Homebrew.failed = true
@show_summary_heading = true @show_summary_heading = true

View File

@ -50,7 +50,7 @@ class FormulaVersions
rescue *IGNORED_EXCEPTIONS => e rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and # We rescue these so that we can skip bad versions and
# continue walking the history # continue walking the history
odebug "#{e} in #{name} at revision #{rev}", e.backtrace if debug? odebug "#{e} in #{name} at revision #{rev}", e.backtrace
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
ensure ensure
@ -69,7 +69,7 @@ class FormulaVersions
end end
return map if versions_seen > MAX_VERSIONS_DEPTH return map if versions_seen > MAX_VERSIONS_DEPTH
rescue MacOSVersionError => e rescue MacOSVersionError => e
odebug "#{e} in #{name} at revision #{rev}" if debug? odebug "#{e} in #{name} at revision #{rev}"
break break
end end
map map

View File

@ -225,10 +225,10 @@ module Formulary
def load_file(flags:) def load_file(flags:)
if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url # rubocop:disable Style/CaseLikeIf if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url # rubocop:disable Style/CaseLikeIf
raise UsageError, "Installation of #{formula_name} from a GitHub commit URL is unsupported! " \ raise UsageError, "Installation of #{formula_name} from a GitHub commit URL is unsupported! " \
"'brew extract #{formula_name}' to stable tap on GitHub instead." "`brew extract #{formula_name}` to a stable tap on GitHub instead."
elsif url.match?(%r{^(https?|ftp)://}) elsif url.match?(%r{^(https?|ftp)://})
raise UsageError, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! ", raise UsageError, "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 "\ "`brew extract` or `brew create` and `brew tap-new` to create a "\
"formula file in a tap on GitHub instead." "formula file in a tap on GitHub instead."
end end
HOMEBREW_CACHE_FORMULA.mkpath HOMEBREW_CACHE_FORMULA.mkpath

View File

@ -603,7 +603,7 @@ class Keg
begin begin
keg = Keg.for(src) keg = Keg.for(src)
rescue NotAKegError rescue NotAKegError
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if verbose puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar." if verbose
return return
end end

View File

@ -15,9 +15,9 @@ module Language
def self.stage_deps(resources, target) def self.stage_deps(resources, target)
if resources.empty? if resources.empty?
if Homebrew::EnvConfig.developer? if Homebrew::EnvConfig.developer?
odie "tried to stage empty Language::Go resources array" odie "Tried to stage empty Language::Go resources array"
else else
opoo "tried to stage empty Language::Go resources array" opoo "Tried to stage empty Language::Go resources array"
end end
end end
resources.grep(Resource::Go) { |resource| resource.stage(target) } resources.grep(Resource::Go) { |resource| resource.stage(target) }

View File

@ -492,7 +492,7 @@ module Homebrew
end end
if livecheck_strategy.present? && livecheck_url.blank? if livecheck_strategy.present? && livecheck_url.blank?
odebug "#{strategy_name} strategy requires a url" odebug "#{strategy_name} strategy requires a URL"
next next
end end

View File

@ -104,7 +104,7 @@ can take several different forms:
* An arbitrary file: * An arbitrary file:
Homebrew can install formulae from a local path. It can point to either a Homebrew can install formulae from a local path. It can point to either a
formula file or a bottle. formula file or a bottle.
Prefix relative paths with `./` to prevent them being interpreted as a Prefix relative paths with `./` to prevent them from being interpreted as a
formula or tap name. formula or tap name.
## SPECIFYING CASKS ## SPECIFYING CASKS

View File

@ -17,8 +17,8 @@ class Migrator
class MigrationNeededError < RuntimeError class MigrationNeededError < RuntimeError
def initialize(formula) def initialize(formula)
super <<~EOS super <<~EOS
#{formula.oldname} was renamed to #{formula.name} and needs to be migrated. #{formula.oldname} was renamed to #{formula.name} and needs to be migrated by running:
Please run `brew migrate #{formula.oldname}` brew migrate #{formula.oldname}
EOS EOS
end end
end end
@ -48,7 +48,8 @@ class Migrator
super <<~EOS super <<~EOS
#{formula.name} from #{formula.tap} is given, but old name #{formula.oldname} was installed from #{tap || "path or url"}. #{formula.name} from #{formula.tap} is given, but old name #{formula.oldname} was installed from #{tap || "path or url"}.
#{msg}To force migration use `brew migrate --force #{formula.oldname}`. #{msg}To force migration, run:
brew migrate --force #{formula.oldname}
EOS EOS
end end
end end
@ -220,7 +221,7 @@ class Migrator
rescue Interrupt rescue Interrupt
ignore_interrupts { backup_oldname } ignore_interrupts { backup_oldname }
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Error occurred while migrating." onoe "The migration did not complete successfully."
puts e puts e
puts e.backtrace if debug? puts e.backtrace if debug?
puts "Backing up..." puts "Backing up..."
@ -314,14 +315,14 @@ class Migrator
begin begin
new_keg.link(overwrite: true, verbose: verbose?) new_keg.link(overwrite: true, verbose: verbose?)
rescue Keg::ConflictError => e rescue Keg::ConflictError => e
onoe "Error while executing `brew link` step on #{newname}" onoe "The `brew link` step did not complete successfully."
puts e puts e
puts puts
puts "Possible conflicting files are:" puts "Possible conflicting files are:"
new_keg.link(dry_run: true, overwrite: true, verbose: verbose?) new_keg.link(dry_run: true, overwrite: true, verbose: verbose?)
raise raise
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "Error while linking" onoe "The `brew link` step did not complete successfully."
puts e puts e
puts puts
puts "You can try again using:" puts "You can try again using:"

View File

@ -141,7 +141,7 @@ module Homebrew
ohai "Searching for a previously deleted formula (in the last month)..." ohai "Searching for a previously deleted formula (in the last month)..."
if (tap.path/".git/shallow").exist? if (tap.path/".git/shallow").exist?
opoo <<~EOS opoo <<~EOS
#{tap} is shallow clone. To get complete history run: #{tap} is shallow clone. To get its complete history, run:
git -C "$(brew --repo #{tap})" fetch --unshallow git -C "$(brew --repo #{tap})" fetch --unshallow
EOS EOS
@ -168,10 +168,10 @@ module Homebrew
#{name} was deleted from #{tap.name} in commit #{short_hash}: #{name} was deleted from #{tap.name} in commit #{short_hash}:
#{commit_message} #{commit_message}
To show the formula before removal run: To show the formula before removal, run:
git -C "$(brew --repo #{tap})" show #{short_hash}^:#{relative_path} git -C "$(brew --repo #{tap})" show #{short_hash}^:#{relative_path}
If you still use this formula consider creating your own tap: If you still use this formula, consider creating your own tap:
#{Formatter.url("https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap")} #{Formatter.url("https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap")}
EOS EOS
end end

View File

@ -65,9 +65,6 @@ class Mktemp
ignore_interrupts { rm_rf(tmpdir) } unless retain? ignore_interrupts { rm_rf(tmpdir) } unless retain?
end end
ensure ensure
if retain? && !@tmpdir.nil? && !@quiet ohai "Temporary files retained at:", @tmpdir.to_s if retain? && !@tmpdir.nil? && !@quiet
ohai "Kept temporary files"
puts "Temporary files retained at #{@tmpdir}"
end
end end
end end

View File

@ -160,7 +160,7 @@ module ELFShim
def save_using_patchelf(new_interpreter, new_rpath) def save_using_patchelf(new_interpreter, new_rpath)
patchelf = DevelopmentTools.locate "patchelf" patchelf = DevelopmentTools.locate "patchelf"
odie "Could not locate patchelf, please: brew install patchelf." if patchelf.blank? odie "Could not locate `patchelf`; please run `brew install patchelf`" if patchelf.blank?
args = [] args = []
args << "--set-interpreter" << new_interpreter if new_interpreter.present? args << "--set-interpreter" << new_interpreter if new_interpreter.present?
args << "--force-rpath" << "--set-rpath" << new_rpath if new_rpath.present? args << "--force-rpath" << "--set-rpath" << new_rpath if new_rpath.present?

View File

@ -266,7 +266,7 @@ module OS
Update them from Software Update in #{software_update_location} or run: Update them from Software Update in #{software_update_location} or run:
softwareupdate --all --install --force softwareupdate --all --install --force
If that doesn't show you an update run: If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install sudo xcode-select --install

View File

@ -150,7 +150,7 @@ class Resource
def verify_download_integrity(fn) def verify_download_integrity(fn)
if fn.file? if fn.file?
ohai "Verifying checksum for '#{fn.basename}'." if verbose? ohai "Verifying checksum for '#{fn.basename}'" if verbose?
fn.verify_checksum(checksum) fn.verify_checksum(checksum)
end end
rescue ChecksumMissingError rescue ChecksumMissingError

View File

@ -293,7 +293,7 @@ module RuboCop
next if url_has_revision?(parameters(url).last) next if url_has_revision?(parameters(url).last)
offending_node(url) offending_node(url)
problem "Formulae in homebrew/core should specify a revision for git urls" problem "Formulae in homebrew/core should specify a revision for git URLs"
end end
end end
@ -316,7 +316,7 @@ module RuboCop
next if url_has_tag?(parameters(url).last) next if url_has_tag?(parameters(url).last)
offending_node(url) offending_node(url)
problem "Formulae in homebrew/core should specify a tag for git urls" problem "Formulae in homebrew/core should specify a tag for git URLs"
end end
end end

View File

@ -127,8 +127,7 @@ class Sandbox
end end
if @failed && Homebrew::EnvConfig.verbose? if @failed && Homebrew::EnvConfig.verbose?
ohai "Sandbox log" ohai "Sandbox Log", logs
puts logs
$stdout.flush # without it, brew test-bot would fail to catch the log $stdout.flush # without it, brew test-bot would fail to catch the log
end end
end end

View File

@ -356,7 +356,7 @@ class BottleSpecification
if [HOMEBREW_DEFAULT_PREFIX, if [HOMEBREW_DEFAULT_PREFIX,
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_PREFIX,
HOMEBREW_LINUX_DEFAULT_PREFIX].exclude?(prefix) HOMEBREW_LINUX_DEFAULT_PREFIX].exclude?(prefix)
odeprecated "setting `prefix` for bottles" odeprecated "setting 'prefix' for bottles"
end end
@prefix = prefix @prefix = prefix
end end

View File

@ -89,7 +89,7 @@ class SystemCommand
env.each_key do |name| env.each_key do |name|
next if /^[\w&&\D]\w*$/.match?(name) next if /^[\w&&\D]\w*$/.match?(name)
raise ArgumentError, "Invalid variable name: '#{name}'" raise ArgumentError, "Invalid variable name: #{name}"
end end
@env = env @env = env
@input = Array(input) @input = Array(input)

View File

@ -209,7 +209,7 @@ class Tap
return "N/A" unless installed? return "N/A" unless installed?
pretty_revision = git_short_head pretty_revision = git_short_head
return "(no git repository)" unless pretty_revision return "(no Git repository)" unless pretty_revision
"(git revision #{pretty_revision}; last commit #{git_last_commit_date})" "(git revision #{pretty_revision}; last commit #{git_last_commit_date})"
end end

View File

@ -26,8 +26,8 @@ begin
trap("INT", old_trap) trap("INT", old_trap)
if Homebrew::EnvConfig.developer? || ENV["CI"].present? if Homebrew::EnvConfig.developer? || ENV["CI"].present?
raise "cannot find child processes without `pgrep`, please install!" unless which("pgrep") raise "Cannot find child processes without `pgrep`, please install!" unless which("pgrep")
raise "cannot kill child processes without `pkill`, please install!" unless which("pkill") raise "Cannot kill child processes without `pkill`, please install!" unless which("pkill")
end end
formula = T.must(args.named.to_resolved_formulae.first) formula = T.must(args.named.to_resolved_formulae.first)

View File

@ -25,7 +25,7 @@ describe "Bash" do
end end
context "every `.sh` file" do context "every `.sh` file" do
it "has valid bash syntax" do it "has valid Bash syntax" do
Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |path| Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |path|
relative_path = path.relative_path_from(HOMEBREW_LIBRARY_PATH) relative_path = path.relative_path_from(HOMEBREW_LIBRARY_PATH)
next if relative_path.to_s.start_with?("shims/", "test/", "vendor/") next if relative_path.to_s.start_with?("shims/", "test/", "vendor/")
@ -42,7 +42,7 @@ describe "Bash" do
end end
context "every shim script" do context "every shim script" do
it "has valid bash syntax" do it "has valid Bash syntax" do
# These have no file extension, but can be identified by their shebang. # These have no file extension, but can be identified by their shebang.
(HOMEBREW_LIBRARY_PATH/"shims").find do |path| (HOMEBREW_LIBRARY_PATH/"shims").find do |path|
next if path.directory? next if path.directory?

View File

@ -89,8 +89,8 @@ describe Cask::Artifact::App, :cask do
describe "target is both writable and user-owned" do describe "target is both writable and user-owned" do
it "overwrites the existing app" do it "overwrites the existing app" do
stdout = <<~EOS stdout = <<~EOS
==> Removing App '#{target_path}'. ==> Removing App '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'. ==> Moving App 'Caffeine.app' to '#{target_path}'
EOS EOS
stderr = <<~EOS stderr = <<~EOS
@ -137,8 +137,8 @@ describe Cask::Artifact::App, :cask do
).and_call_original ).and_call_original
stdout = <<~EOS stdout = <<~EOS
==> Removing App '#{target_path}'. ==> Removing App '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'. ==> Moving App 'Caffeine.app' to '#{target_path}'
EOS EOS
stderr = <<~EOS stderr = <<~EOS
@ -180,8 +180,8 @@ describe Cask::Artifact::App, :cask do
it "overwrites the existing app" do it "overwrites the existing app" do
stdout = <<~EOS stdout = <<~EOS
==> Removing App '#{target_path}'. ==> Removing App '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'. ==> Moving App 'Caffeine.app' to '#{target_path}'
EOS EOS
stderr = <<~EOS stderr = <<~EOS

View File

@ -18,7 +18,7 @@ describe Cask::Artifact::Installer, :cask do
it "shows a message prompting to run the installer manually" do it "shows a message prompting to run the installer manually" do
expect { expect {
installer.install_phase(command: command) installer.install_phase(command: command)
}.to output(%r{run the installer at:\s+'#{staged_path}/installer'}).to_stdout }.to output(%r{run the installer at:\s+#{staged_path}/installer}).to_stdout
end end
end end

View File

@ -917,7 +917,7 @@ describe Cask::Audit, :cask do
RUBY RUBY
end end
it { is_expected.to fail_with(/a `verified` parameter has to be added/) } it { is_expected.to fail_with(/a 'verified' parameter has to be added/) }
end end
context "when the url does not match the homepage with verified" do context "when the url does not match the homepage with verified" do

View File

@ -41,13 +41,13 @@ describe Cask::Cask, :cask do
expect(c.token).to eq("local-caffeine") expect(c.token).to eq("local-caffeine")
end end
it "returns an instance of the Cask from a url" do it "returns an instance of the Cask from a URL" do
c = Cask::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb") c = Cask::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb")
expect(c).to be_kind_of(described_class) expect(c).to be_kind_of(described_class)
expect(c.token).to eq("local-caffeine") expect(c.token).to eq("local-caffeine")
end end
it "raises an error when failing to download a Cask from a url" do it "raises an error when failing to download a Cask from a URL" do
expect { expect {
url = "file://#{tap_path}/Casks/notacask.rb" url = "file://#{tap_path}/Casks/notacask.rb"

Some files were not shown because too many files have changed in this diff Show More