output: express environment variables consistently

This commit is contained in:
Eric Knibbe 2025-08-02 23:27:59 -04:00
parent 9e4bedad2f
commit 6255263b51
No known key found for this signature in database
42 changed files with 87 additions and 81 deletions

View File

@ -180,7 +180,7 @@ module Homebrew
<<~EOS <<~EOS
Your shell has been configured to use a build environment from your `Brewfile`. Your shell has been configured to use a build environment from your `Brewfile`.
This should help you build stuff. This should help you build stuff.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
When done, type `exit`. When done, type `exit`.
EOS EOS
end end

View File

@ -32,7 +32,7 @@ module Cask
def self.all(eval_all: false) def self.all(eval_all: false)
if !eval_all && !Homebrew::EnvConfig.eval_all? if !eval_all && !Homebrew::EnvConfig.eval_all?
raise ArgumentError, "Cask::Cask#all cannot be used without `--eval-all` or HOMEBREW_EVAL_ALL" raise ArgumentError, "Cask::Cask#all cannot be used without `--eval-all` or `HOMEBREW_EVAL_ALL=1`"
end end
# Load core casks from tokens so they load from the API when the core cask is not tapped. # Load core casks from tokens so they load from the API when the core cask is not tapped.

View File

@ -248,7 +248,7 @@ on_request: true)
raise CaskError, <<~EOS raise CaskError, <<~EOS
Cask '#{@cask}' does not have a sha256 checksum defined and was not installed. Cask '#{@cask}' does not have a sha256 checksum defined and was not installed.
This means you have the #{Formatter.identifier("--require-sha")} option set, perhaps in your HOMEBREW_CASK_OPTS. This means you have the #{Formatter.identifier("--require-sha")} option set, perhaps in your `$HOMEBREW_CASK_OPTS`.
EOS EOS
end end
@ -703,9 +703,9 @@ on_request: true)
dep_full_name = cask_or_formula.full_name dep_full_name = cask_or_formula.full_name
error_message = "The installation of #{@cask} has a dependency #{dep_full_name}\n" \ error_message = "The installation of #{@cask} has a dependency #{dep_full_name}\n" \
"from the #{dep_tap} tap but #{owner} " "from the #{dep_tap} tap but #{owner} "
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless dep_tap.allowed_by_env? error_message << "has not allowed this tap in `$HOMEBREW_ALLOWED_TAPS`" unless dep_tap.allowed_by_env?
error_message << " and\n" if !dep_tap.allowed_by_env? && dep_tap.forbidden_by_env? error_message << " and\n" if !dep_tap.allowed_by_env? && dep_tap.forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if dep_tap.forbidden_by_env? error_message << "has forbidden this tap in `$HOMEBREW_FORBIDDEN_TAPS`" if dep_tap.forbidden_by_env?
error_message << ".#{owner_contact}" error_message << ".#{owner_contact}"
raise CaskCannotBeInstalledError.new(@cask, error_message) raise CaskCannotBeInstalledError.new(@cask, error_message)
@ -717,9 +717,9 @@ on_request: true)
error_message = "The installation of #{@cask.full_name} has the tap #{cask_tap}\n" \ error_message = "The installation of #{@cask.full_name} has the tap #{cask_tap}\n" \
"but #{owner} " "but #{owner} "
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless cask_tap.allowed_by_env? error_message << "has not allowed this tap in `$HOMEBREW_ALLOWED_TAPS`" unless cask_tap.allowed_by_env?
error_message << " and\n" if !cask_tap.allowed_by_env? && cask_tap.forbidden_by_env? error_message << " and\n" if !cask_tap.allowed_by_env? && cask_tap.forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if cask_tap.forbidden_by_env? error_message << "has forbidden this tap in `$HOMEBREW_FORBIDDEN_TAPS`" if cask_tap.forbidden_by_env?
error_message << ".#{owner_contact}" error_message << ".#{owner_contact}"
raise CaskCannotBeInstalledError.new(@cask, error_message) raise CaskCannotBeInstalledError.new(@cask, error_message)

View File

@ -258,8 +258,8 @@ module Homebrew
return if Homebrew::EnvConfig.no_env_hints? return if Homebrew::EnvConfig.no_env_hints?
return if Homebrew::EnvConfig.no_install_cleanup? return if Homebrew::EnvConfig.no_install_cleanup?
puts "Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP." puts "Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`."
puts "Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`)." puts "Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`)."
end end
def self.puts_no_install_cleanup_disable_message_if_not_already! def self.puts_no_install_cleanup_disable_message_if_not_already!
@ -315,8 +315,8 @@ module Homebrew
end end
if ENV["HOMEBREW_AUTOREMOVE"].present? if ENV["HOMEBREW_AUTOREMOVE"].present?
opoo "HOMEBREW_AUTOREMOVE is now a no-op as it is the default behaviour. " \ opoo "`$HOMEBREW_AUTOREMOVE` is now a no-op as it is the default behaviour. " \
"Set HOMEBREW_NO_AUTOREMOVE=1 to disable it." "Set `HOMEBREW_NO_AUTOREMOVE=1` to disable it."
end end
Cleanup.autoremove(dry_run: dry_run?) unless Homebrew::EnvConfig.no_autoremove? Cleanup.autoremove(dry_run: dry_run?) unless Homebrew::EnvConfig.no_autoremove?

View File

@ -130,7 +130,7 @@ module Homebrew
opoo <<~EOS opoo <<~EOS
`brew deps` is not the actual runtime dependencies because #{not_using_runtime_dependencies_reason}! `brew deps` is not the actual runtime dependencies because #{not_using_runtime_dependencies_reason}!
This means dependencies may differ from a formula's declared dependencies. This means dependencies may differ from a formula's declared dependencies.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
EOS EOS
end end

View File

@ -49,7 +49,7 @@ module Homebrew
if search_type.present? if search_type.present?
if !args.eval_all? && Homebrew::EnvConfig.no_install_from_api? if !args.eval_all? && Homebrew::EnvConfig.no_install_from_api?
raise UsageError, "`brew desc --search` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
query = args.named.join(" ") query = args.named.join(" ")

View File

@ -63,7 +63,9 @@ module Homebrew
files["00.tap.out"] = { content: tap } files["00.tap.out"] = { content: tap }
end end
odie "`brew gist-logs` requires HOMEBREW_GITHUB_API_TOKEN to be set!" if GitHub::API.credentials_type == :none if GitHub::API.credentials_type == :none
odie "`brew gist-logs` requires `$HOMEBREW_GITHUB_API_TOKEN` to be set!"
end
# Description formatted to work well as page title when viewing gist # Description formatted to work well as page title when viewing gist
descr = if formula.core_formula? descr = if formula.core_formula?

View File

@ -50,7 +50,7 @@ module Homebrew
taps = if args.no_named? taps = if args.no_named?
unless args.eval_all? unless args.eval_all?
raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
Tap.installed Tap.installed

View File

@ -72,7 +72,7 @@ module Homebrew
if args.desc? if args.desc?
if !args.eval_all? && Homebrew::EnvConfig.no_install_from_api? if !args.eval_all? && Homebrew::EnvConfig.no_install_from_api?
raise UsageError, "`brew search --desc` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew search --desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
Search.search_descriptions(string_or_regex, args) Search.search_descriptions(string_or_regex, args)

View File

@ -78,8 +78,8 @@ module Homebrew
end end
if ENV["HOMEBREW_AUTOREMOVE"].present? if ENV["HOMEBREW_AUTOREMOVE"].present?
opoo "HOMEBREW_AUTOREMOVE is now a no-op as it is the default behaviour. " \ opoo "`$HOMEBREW_AUTOREMOVE` is now a no-op as it is the default behaviour. " \
"Set HOMEBREW_NO_AUTOREMOVE=1 to disable it." "Set `HOMEBREW_NO_AUTOREMOVE=1` to disable it."
end end
Cleanup.autoremove unless Homebrew::EnvConfig.no_autoremove? Cleanup.autoremove unless Homebrew::EnvConfig.no_autoremove?
end end

View File

@ -56,7 +56,7 @@ module Homebrew
if Homebrew::EnvConfig.core_git_remote != HOMEBREW_CORE_DEFAULT_GIT_REMOTE if Homebrew::EnvConfig.core_git_remote != HOMEBREW_CORE_DEFAULT_GIT_REMOTE
opoo <<~EOS opoo <<~EOS
HOMEBREW_CORE_GIT_REMOTE was set: #{Homebrew::EnvConfig.core_git_remote}. `$HOMEBREW_CORE_GIT_REMOTE` was set: #{Homebrew::EnvConfig.core_git_remote}.
It has been unset for the migration. It has been unset for the migration.
You may need to change this from a linuxbrew-core mirror to a homebrew-core one. You may need to change this from a linuxbrew-core mirror to a homebrew-core one.
@ -66,7 +66,7 @@ module Homebrew
if Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN if Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
opoo <<~EOS opoo <<~EOS
HOMEBREW_BOTTLE_DOMAIN was set: #{Homebrew::EnvConfig.bottle_domain}. `$HOMEBREW_BOTTLE_DOMAIN` was set: #{Homebrew::EnvConfig.bottle_domain}.
It has been unset for the migration. It has been unset for the migration.
You may need to change this from a Linuxbrew package mirror to a Homebrew one. You may need to change this from a Linuxbrew package mirror to a Homebrew one.
@ -412,9 +412,9 @@ module Homebrew
!Homebrew::EnvConfig.automatically_set_no_install_from_api? !Homebrew::EnvConfig.automatically_set_no_install_from_api?
return unless no_install_from_api_set return unless no_install_from_api_set
ohai "You have HOMEBREW_NO_INSTALL_FROM_API set" ohai "You have `$HOMEBREW_NO_INSTALL_FROM_API` set"
puts "Homebrew >=4.1.0 is dramatically faster and less error-prone when installing" puts "Homebrew >=4.1.0 is dramatically faster and less error-prone when installing"
puts "from the JSON API. Please consider unsetting HOMEBREW_NO_INSTALL_FROM_API." puts "from the JSON API. Please consider unsetting `$HOMEBREW_NO_INSTALL_FROM_API`."
puts "This message will only be printed once." puts "This message will only be printed once."
puts "\n\n" puts "\n\n"

View File

@ -52,6 +52,8 @@ homebrew-update-reset() {
if [[ -z "${REPOS[*]}" ]] if [[ -z "${REPOS[*]}" ]]
then then
# HOMEBREW_REPOSITORY is set by bin/brew
# shellcheck disable=SC2154
REPOS+=("${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*) REPOS+=("${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*)
fi fi
@ -71,7 +73,7 @@ homebrew-update-reset() {
echo echo
ohai "Resetting ${DIR}..." ohai "Resetting ${DIR}..."
# HOMEBREW_* variables here may all set by bin/brew or the user # HOMEBREW_* variables here may all be set by bin/brew or the user
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" &&
(-n "${HOMEBREW_UPDATE_TO_TAG}" || (-n "${HOMEBREW_UPDATE_TO_TAG}" ||

View File

@ -650,9 +650,9 @@ EOS
if [[ -z "${HOMEBREW_NO_ENV_HINTS}" && -z "${HOMEBREW_AUTO_UPDATE_SECS}" ]] if [[ -z "${HOMEBREW_NO_ENV_HINTS}" && -z "${HOMEBREW_AUTO_UPDATE_SECS}" ]]
then then
# shellcheck disable=SC2016 # shellcheck disable=SC2016
echo 'Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with' >&2 echo 'Adjust how often this is run with `$HOMEBREW_AUTO_UPDATE_SECS` or disable with' >&2
# shellcheck disable=SC2016 # shellcheck disable=SC2016
echo 'HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).' >&2 echo '`$HOMEBREW_NO_AUTO_UPDATE=1`. Hide these hints with `$HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).' >&2
fi fi
else else
ohai 'Updating Homebrew...' >&2 ohai 'Updating Homebrew...' >&2

View File

@ -123,7 +123,7 @@ module Homebrew
eval_all = args.eval_all? eval_all = args.eval_all?
if !args.installed? && !eval_all if !args.installed? && !eval_all
raise UsageError, "`brew uses` needs `--installed` or `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew uses` needs `--installed` or `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
if show_formulae_and_casks || args.formula? if show_formulae_and_casks || args.formula?

View File

@ -143,7 +143,7 @@ module Homebrew
unless eval_all unless eval_all
# This odisabled should probably stick around indefinitely. # This odisabled should probably stick around indefinitely.
odisabled "brew audit", odisabled "brew audit",
"brew audit --eval-all or HOMEBREW_EVAL_ALL" "`brew audit --eval-all` or set `HOMEBREW_EVAL_ALL=1`"
end end
no_named_args = true no_named_args = true
[ [

View File

@ -117,7 +117,7 @@ module Homebrew
else else
raise UsageError, raise UsageError,
"`brew bump` without named arguments needs `--installed` or `--eval-all` passed or " \ "`brew bump` without named arguments needs `--installed` or `--eval-all` passed or " \
"`$HOMEBREW_EVAL_ALL` set!" "`HOMEBREW_EVAL_ALL=1` set!"
end end
if args.start_with if args.start_with

View File

@ -22,7 +22,7 @@ module Homebrew
env: :eval_all env: :eval_all
switch "--dependents", switch "--dependents",
description: "Determine runners for testing dependents. " \ description: "Determine runners for testing dependents. " \
"Requires `--eval-all` or `$HOMEBREW_EVAL_ALL` to be set.", "Requires `--eval-all` or `HOMEBREW_EVAL_ALL=1` to be set.",
depends_on: "--eval-all" depends_on: "--eval-all"
named_args max: 2 named_args max: 2

View File

@ -109,10 +109,10 @@ module Homebrew
return if args.setup? return if args.setup?
odie "HOMEBREW_NO_ANALYTICS is set!" if ENV["HOMEBREW_NO_ANALYTICS"] odie "`$HOMEBREW_NO_ANALYTICS` is set!" if ENV["HOMEBREW_NO_ANALYTICS"]
token = ENV.fetch("HOMEBREW_INFLUXDB_TOKEN", nil) token = ENV.fetch("HOMEBREW_INFLUXDB_TOKEN", nil)
odie "No InfluxDB credentials found in HOMEBREW_INFLUXDB_TOKEN!" unless token odie "No InfluxDB credentials found in `$HOMEBREW_INFLUXDB_TOKEN`!" unless token
client = InfluxDBClient3.new( client = InfluxDBClient3.new(
token:, token:,
@ -203,7 +203,7 @@ module Homebrew
client.query(query:, language: "sql").to_batches client.query(query:, language: "sql").to_batches
rescue PyCall::PyError => e rescue PyCall::PyError => e
if e.message.include?("message: unauthenticated") if e.message.include?("message: unauthenticated")
odie "Could not authenticate with InfluxDB! Please check your HOMEBREW_INFLUXDB_TOKEN!" odie "Could not authenticate with InfluxDB! Please check your `$HOMEBREW_INFLUXDB_TOKEN`!"
end end
raise raise
end end

View File

@ -481,7 +481,7 @@ module Homebrew
name = "#{tap.name}/#{File.basename(line.chomp, ".rb")}" name = "#{tap.name}/#{File.basename(line.chomp, ".rb")}"
if Homebrew::EnvConfig.disable_load_formula? if Homebrew::EnvConfig.disable_load_formula?
opoo "Can't check if updated bottles are necessary as HOMEBREW_DISABLE_LOAD_FORMULA is set!" opoo "Can't check if updated bottles are necessary as `$HOMEBREW_DISABLE_LOAD_FORMULA` is set!"
break break
end end
begin begin

View File

@ -55,7 +55,7 @@ module Homebrew
gem and pip will ignore our configuration and insist on using the gem and pip will ignore our configuration and insist on using the
environment they were built under (mostly). Sadly, scons will also environment they were built under (mostly). Sadly, scons will also
ignore our configuration. ignore our configuration.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
When done, type `exit`. When done, type `exit`.
EOS EOS
end end

View File

@ -68,7 +68,7 @@ module Homebrew
eval_all = args.eval_all? eval_all = args.eval_all?
if args.total? && !eval_all if args.total? && !eval_all
raise UsageError, "`brew unbottled --total` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew unbottled --total` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
if args.named.blank? if args.named.blank?
@ -116,7 +116,7 @@ module Homebrew
formulae = all_formulae = args.named.to_formulae formulae = all_formulae = args.named.to_formulae
elsif args.dependents? elsif args.dependents?
unless eval_all unless eval_all
raise UsageError, "`brew unbottled --dependents` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew unbottled --dependents` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!"
end end
formulae = all_formulae = Formula.all(eval_all:) formulae = all_formulae = Formula.all(eval_all:)

View File

@ -475,7 +475,7 @@ module Homebrew
which resolves to: #{HOMEBREW_CELLAR.realpath} which resolves to: #{HOMEBREW_CELLAR.realpath}
The recommended Homebrew installations are either: The recommended Homebrew installations are either:
(A) Have Cellar be a real directory inside of your HOMEBREW_PREFIX (A) Have Cellar be a real directory inside of your `$HOMEBREW_PREFIX`
(B) Symlink "bin/brew" into your prefix, but don't symlink "Cellar". (B) Symlink "bin/brew" into your prefix, but don't symlink "Cellar".
Older installations of Homebrew may have created a symlinked Cellar, but this can Older installations of Homebrew may have created a symlinked Cellar, but this can

View File

@ -609,7 +609,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
if Homebrew::EnvConfig.no_insecure_redirect? && if Homebrew::EnvConfig.no_insecure_redirect? &&
url.start_with?("https://") && !resolved_url.start_with?("https://") url.start_with?("https://") && !resolved_url.start_with?("https://")
$stderr.puts "HTTPS to HTTP redirect detected and HOMEBREW_NO_INSECURE_REDIRECT is set." $stderr.puts "HTTPS to HTTP redirect detected and `$HOMEBREW_NO_INSECURE_REDIRECT` is set."
raise CurlDownloadStrategyError, url raise CurlDownloadStrategyError, url
end end

View File

@ -331,9 +331,9 @@ end
class TapCoreRemoteMismatchError < TapRemoteMismatchError class TapCoreRemoteMismatchError < TapRemoteMismatchError
def message def message
<<~EOS <<~EOS
Tap #{name} remote does not match HOMEBREW_CORE_GIT_REMOTE. Tap #{name} remote does not match `$HOMEBREW_CORE_GIT_REMOTE`.
#{expected_remote} != #{actual_remote} #{expected_remote} != #{actual_remote}
Please set HOMEBREW_CORE_GIT_REMOTE="#{actual_remote}" and run `brew update` instead. Please set `HOMEBREW_CORE_GIT_REMOTE="#{actual_remote}"` and run `brew update` instead.
EOS EOS
end end
end end

View File

@ -381,8 +381,8 @@ module Kernel
unless silent unless silent
opoo <<~EOS opoo <<~EOS
Using #{editor} because no editor was set in the environment. Using #{editor} because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR This may change in the future, so we recommend setting `$EDITOR`
or HOMEBREW_EDITOR to your preferred text editor. or `$HOMEBREW_EDITOR` to your preferred text editor.
EOS EOS
end end

View File

@ -37,7 +37,7 @@ module OS
message + <<~EOS message + <<~EOS
If you don't have administrative privileges on this machine, If you don't have administrative privileges on this machine,
create a directory and set the HOMEBREW_TEMP environment variable, create a directory and set the `$HOMEBREW_TEMP` environment variable,
for example: for example:
install -d -m 1755 ~/tmp install -d -m 1755 ~/tmp
#{Utils::Shell.set_variable_in_profile("HOMEBREW_TEMP", "~/tmp")} #{Utils::Shell.set_variable_in_profile("HOMEBREW_TEMP", "~/tmp")}
@ -53,7 +53,7 @@ module OS
<<~EOS <<~EOS
The directory #{HOMEBREW_TEMP} does not permit executing The directory #{HOMEBREW_TEMP} does not permit executing
programs. It is likely mounted as "noexec". Please set HOMEBREW_TEMP programs. It is likely mounted as "noexec". Please set `$HOMEBREW_TEMP`
in your #{Utils::Shell.profile} to a different directory, for example: in your #{Utils::Shell.profile} to a different directory, for example:
export HOMEBREW_TEMP=~/tmp export HOMEBREW_TEMP=~/tmp
echo 'export HOMEBREW_TEMP=~/tmp' >> #{Utils::Shell.profile} echo 'export HOMEBREW_TEMP=~/tmp' >> #{Utils::Shell.profile}
@ -148,7 +148,7 @@ module OS
return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew") return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew")
<<~EOS <<~EOS
Your HOMEBREW_BOTTLE_DOMAIN still contains "linuxbrew". Your `$HOMEBREW_BOTTLE_DOMAIN` still contains "linuxbrew".
You must unset it (or adjust it to not contain linuxbrew You must unset it (or adjust it to not contain linuxbrew
e.g. by using homebrew instead). e.g. by using homebrew instead).
EOS EOS

View File

@ -1973,7 +1973,7 @@ class Formula
sig { params(source: Pathname, target: Pathname).returns(String) } sig { params(source: Pathname, target: Pathname).returns(String) }
def rpath(source: bin, target: lib) def rpath(source: bin, target: lib)
unless target.to_s.start_with?(HOMEBREW_PREFIX) unless target.to_s.start_with?(HOMEBREW_PREFIX)
raise "rpath `target` should only be used for paths inside HOMEBREW_PREFIX!" raise "rpath `target` should only be used for paths inside `$HOMEBREW_PREFIX`!"
end end
"#{loader_path}/#{target.relative_path_from(source)}" "#{loader_path}/#{target.relative_path_from(source)}"
@ -2244,7 +2244,7 @@ class Formula
sig { params(eval_all: T::Boolean).returns(T::Array[Formula]) } sig { params(eval_all: T::Boolean).returns(T::Array[Formula]) }
def self.all(eval_all: false) def self.all(eval_all: false)
if !eval_all && !Homebrew::EnvConfig.eval_all? if !eval_all && !Homebrew::EnvConfig.eval_all?
raise ArgumentError, "Formula#all without `--eval-all` or HOMEBREW_EVAL_ALL" raise ArgumentError, "Formula#all cannot be used without `--eval-all` or `HOMEBREW_EVAL_ALL=1`"
end end
(core_names + tap_files).filter_map do |name_or_file| (core_names + tap_files).filter_map do |name_or_file|

View File

@ -277,8 +277,8 @@ class FormulaInstaller
prefix = Pathname(bottle.cellar.to_s).parent prefix = Pathname(bottle.cellar.to_s).parent
opoo <<~EOS opoo <<~EOS
Building #{formula.full_name} from source as the bottle needs: Building #{formula.full_name} from source as the bottle needs:
- HOMEBREW_CELLAR: #{bottle.cellar} (yours is #{HOMEBREW_CELLAR}) - `HOMEBREW_CELLAR=#{bottle.cellar}` (yours is #{HOMEBREW_CELLAR})
- HOMEBREW_PREFIX: #{prefix} (yours is #{HOMEBREW_PREFIX}) - `HOMEBREW_PREFIX=#{prefix}` (yours is #{HOMEBREW_PREFIX})
EOS EOS
end end
return false return false
@ -1503,7 +1503,7 @@ on_request: installed_on_request?, options:)
This typically indicates an invalid GitHub API token. This typically indicates an invalid GitHub API token.
If you have `HOMEBREW_GITHUB_API_TOKEN` set, check it is correct If you have `$HOMEBREW_GITHUB_API_TOKEN` set, check it is correct
or unset it and instead run: or unset it and instead run:
gh auth login gh auth login
@ -1517,7 +1517,7 @@ on_request: installed_on_request?, options:)
The bottle for #{formula.name} could not be verified. The bottle for #{formula.name} could not be verified.
This typically indicates a missing GitHub API token, which you This typically indicates a missing GitHub API token, which you
can resolve either by setting `HOMEBREW_GITHUB_API_TOKEN` or can resolve either by setting `$HOMEBREW_GITHUB_API_TOKEN` or
by running: by running:
gh auth login gh auth login
@ -1649,7 +1649,7 @@ on_request: installed_on_request?, options:)
if invalid_licenses.present? if invalid_licenses.present?
opoo <<~EOS opoo <<~EOS
HOMEBREW_FORBIDDEN_LICENSES contains invalid license identifiers: #{invalid_licenses.to_sentence} `$HOMEBREW_FORBIDDEN_LICENSES` contains invalid license identifiers: #{invalid_licenses.to_sentence}
These licenses will not be forbidden. See the valid SPDX license identifiers at: These licenses will not be forbidden. See the valid SPDX license identifiers at:
#{Formatter.url("https://spdx.org/licenses/")} #{Formatter.url("https://spdx.org/licenses/")}
And the licenses for a formula with: And the licenses for a formula with:
@ -1671,7 +1671,7 @@ on_request: installed_on_request?, options:)
raise CannotInstallFormulaError, <<~EOS raise CannotInstallFormulaError, <<~EOS
The installation of #{formula.name} has a dependency on #{dep.name} where all The installation of #{formula.name} has a dependency on #{dep.name} where all
its licenses were forbidden by #{owner} in `HOMEBREW_FORBIDDEN_LICENSES`: its licenses were forbidden by #{owner} in `$HOMEBREW_FORBIDDEN_LICENSES`:
#{SPDX.license_expression_to_string dep_f.license}#{owner_contact} #{SPDX.license_expression_to_string dep_f.license}#{owner_contact}
EOS EOS
end end
@ -1682,7 +1682,7 @@ on_request: installed_on_request?, options:)
return unless SPDX.licenses_forbid_installation? formula.license, forbidden_licenses return unless SPDX.licenses_forbid_installation? formula.license, forbidden_licenses
raise CannotInstallFormulaError, <<~EOS raise CannotInstallFormulaError, <<~EOS
#{formula.name}'s licenses are all forbidden by #{owner} in `HOMEBREW_FORBIDDEN_LICENSES`: #{formula.name}'s licenses are all forbidden by #{owner} in `$HOMEBREW_FORBIDDEN_LICENSES`:
#{SPDX.license_expression_to_string formula.license}#{owner_contact} #{SPDX.license_expression_to_string formula.license}#{owner_contact}
EOS EOS
end end
@ -1703,9 +1703,9 @@ on_request: installed_on_request?, options:)
error_message = "The installation of #{formula.name} has a dependency #{dep.name}\n" \ error_message = "The installation of #{formula.name} has a dependency #{dep.name}\n" \
"from the #{dep_tap} tap but #{owner} " "from the #{dep_tap} tap but #{owner} "
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless dep_tap.allowed_by_env? error_message << "has not allowed this tap in `$HOMEBREW_ALLOWED_TAPS`" unless dep_tap.allowed_by_env?
error_message << " and\n" if !dep_tap.allowed_by_env? && dep_tap.forbidden_by_env? error_message << " and\n" if !dep_tap.allowed_by_env? && dep_tap.forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if dep_tap.forbidden_by_env? error_message << "has forbidden this tap in `$HOMEBREW_FORBIDDEN_TAPS`" if dep_tap.forbidden_by_env?
error_message << ".#{owner_contact}" error_message << ".#{owner_contact}"
raise CannotInstallFormulaError, error_message raise CannotInstallFormulaError, error_message
@ -1719,9 +1719,9 @@ on_request: installed_on_request?, options:)
error_message = "The installation of #{formula.full_name} has the tap #{formula_tap}\n" \ error_message = "The installation of #{formula.full_name} has the tap #{formula_tap}\n" \
"but #{owner} " "but #{owner} "
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless formula_tap.allowed_by_env? error_message << "has not allowed this tap in `$HOMEBREW_ALLOWED_TAPS`" unless formula_tap.allowed_by_env?
error_message << " and\n" if !formula_tap.allowed_by_env? && formula_tap.forbidden_by_env? error_message << " and\n" if !formula_tap.allowed_by_env? && formula_tap.forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if formula_tap.forbidden_by_env? error_message << "has forbidden this tap in `$HOMEBREW_FORBIDDEN_TAPS`" if formula_tap.forbidden_by_env?
error_message << ".#{owner_contact}" error_message << ".#{owner_contact}"
raise CannotInstallFormulaError, error_message raise CannotInstallFormulaError, error_message
@ -1751,7 +1751,7 @@ on_request: installed_on_request?, options:)
raise CannotInstallFormulaError, <<~EOS raise CannotInstallFormulaError, <<~EOS
The installation of #{formula.name} has a dependency #{dep_name} The installation of #{formula.name} has a dependency #{dep_name}
but the #{dep_name} formula was forbidden by #{owner} in `HOMEBREW_FORBIDDEN_FORMULAE`.#{owner_contact} but the #{dep_name} formula was forbidden by #{owner} in `$HOMEBREW_FORBIDDEN_FORMULAE`.#{owner_contact}
EOS EOS
end end
end end
@ -1768,7 +1768,7 @@ on_request: installed_on_request?, options:)
raise CannotInstallFormulaError, <<~EOS raise CannotInstallFormulaError, <<~EOS
The installation of #{formula_name} was forbidden by #{owner} The installation of #{formula_name} was forbidden by #{owner}
in `HOMEBREW_FORBIDDEN_FORMULAE`.#{owner_contact} in `$HOMEBREW_FORBIDDEN_FORMULAE`.#{owner_contact}
EOS EOS
end end

View File

@ -97,7 +97,7 @@ module Formulary
using PathnameWriteMkpath using PathnameWriteMkpath
def self.load_formula(name, path, contents, namespace, flags:, ignore_errors:) def self.load_formula(name, path, contents, namespace, flags:, ignore_errors:)
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula? raise "Formula loading disabled by `$HOMEBREW_DISABLE_LOAD_FORMULA`!" if Homebrew::EnvConfig.disable_load_formula?
require "formula" require "formula"
require "ignorable" require "ignorable"

View File

@ -38,7 +38,7 @@ module RuboCop
end end
if find_node_method_by_name(body_node, :keg_only)&.source&.include?("HOMEBREW_PREFIX") if find_node_method_by_name(body_node, :keg_only)&.source&.include?("HOMEBREW_PREFIX")
problem "`keg_only` reason should not include `HOMEBREW_PREFIX` " \ problem "`keg_only` reason should not include `$HOMEBREW_PREFIX` " \
"as it creates confusing `brew info` output." "as it creates confusing `brew info` output."
end end
end end

View File

@ -90,8 +90,8 @@ module Homebrew
opoo "uid and euid do not match, using user/* instead of gui/* domain!" opoo "uid and euid do not match, using user/* instead of gui/* domain!"
end end
unless Homebrew::EnvConfig.no_env_hints? unless Homebrew::EnvConfig.no_env_hints?
puts "Hide this warning by setting HOMEBREW_SERVICES_NO_DOMAIN_WARNING." puts "Hide this warning by setting `HOMEBREW_SERVICES_NO_DOMAIN_WARNING=1`."
puts "Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`)." puts "Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`)."
end end
@output_warning = T.let(true, T.nilable(TrueClass)) @output_warning = T.let(true, T.nilable(TrueClass))
end end

View File

@ -18,7 +18,7 @@ module Homebrew
private_class_method def self.cache_dir private_class_method def self.cache_dir
cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil) cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil)
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? raise "Needs `$HOMEBREW_CACHE` or `$HOMEBREW_DEFAULT_CACHE`!" if cache.nil? || cache.empty?
File.join(cache, "bootsnap", key) File.join(cache, "bootsnap", key)
end end

View File

@ -201,7 +201,9 @@ class SystemCommand
askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : [] askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : []
user_flags = [] user_flags = []
if Homebrew::EnvConfig.sudo_through_sudo_user? if Homebrew::EnvConfig.sudo_through_sudo_user?
raise ArgumentError, "HOMEBREW_SUDO_THROUGH_SUDO_USER set but SUDO_USER unset!" if homebrew_sudo_user.blank? if homebrew_sudo_user.blank?
raise ArgumentError, "`$HOMEBREW_SUDO_THROUGH_SUDO_USER` set but `$SUDO_USER` unset!"
end
user_flags += ["--prompt", "Password for %p:", "-u", homebrew_sudo_user, user_flags += ["--prompt", "Password for %p:", "-u", homebrew_sudo_user,
*askpass_flags, *askpass_flags,

View File

@ -120,7 +120,7 @@ class Tap
Set.new(allowed_tap_list.filter_map do |tap| Set.new(allowed_tap_list.filter_map do |tap|
Tap.fetch(tap) Tap.fetch(tap)
rescue Tap::InvalidNameError rescue Tap::InvalidNameError
opoo "Invalid tap name in `HOMEBREW_ALLOWED_TAPS`: #{tap}" opoo "Invalid tap name in `$HOMEBREW_ALLOWED_TAPS`: #{tap}"
nil nil
end).freeze end).freeze
end end
@ -135,7 +135,7 @@ class Tap
Set.new(forbidden_tap_list.filter_map do |tap| Set.new(forbidden_tap_list.filter_map do |tap|
Tap.fetch(tap) Tap.fetch(tap)
rescue Tap::InvalidNameError rescue Tap::InvalidNameError
opoo "Invalid tap name in `HOMEBREW_FORBIDDEN_TAPS`: #{tap}" opoo "Invalid tap name in `$HOMEBREW_FORBIDDEN_TAPS`: #{tap}"
nil nil
end).freeze end).freeze
end end
@ -432,9 +432,9 @@ class Tap
end end
error_message = "The installation of the #{full_name} was requested but #{owner}\n" error_message = "The installation of the #{full_name} was requested but #{owner}\n"
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless allowed_by_env? error_message << "has not allowed this tap in `$HOMEBREW_ALLOWED_TAPS`" unless allowed_by_env?
error_message << " and\n" if !allowed_by_env? && forbidden_by_env? error_message << " and\n" if !allowed_by_env? && forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if forbidden_by_env? error_message << "has forbidden this tap in `$HOMEBREW_FORBIDDEN_TAPS`" if forbidden_by_env?
error_message << ".#{owner_contact}" error_message << ".#{owner_contact}"
odie error_message odie error_message

View File

@ -19,7 +19,7 @@ RSpec.describe Homebrew::Cmd::Desc do
setup_test_formula "testball" setup_test_formula "testball"
expect { brew "desc", "--search", "testball" } expect { brew "desc", "--search", "testball" }
.to output(/`brew desc --search` needs `--eval-all` passed or `\$HOMEBREW_EVAL_ALL` set!/).to_stderr .to output(/`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL=1` set!/).to_stderr
.and be_a_failure .and be_a_failure
end end

View File

@ -33,7 +33,7 @@ RSpec.describe TestRunnerFormula do
expect(described_class.new(testball, eval_all: true).eval_all).to be(true) expect(described_class.new(testball, eval_all: true).eval_all).to be(true)
end end
it "takes the value of `HOMEBREW_EVAL_ALL` at instantiation time if not specified" do it "takes the value of HOMEBREW_EVAL_ALL at instantiation time if not specified" do
allow(Homebrew::EnvConfig).to receive(:eval_all?).and_return(true) allow(Homebrew::EnvConfig).to receive(:eval_all?).and_return(true)
expect(described_class.new(testball).eval_all).to be(true) expect(described_class.new(testball).eval_all).to be(true)

View File

@ -323,7 +323,7 @@ RSpec.describe "Utils::Curl" do
end end
describe "::curl_executable" do describe "::curl_executable" do
it "returns `HOMEBREW_BREWED_CURL_PATH` when `use_homebrew_curl` is `true`" do it "returns HOMEBREW_BREWED_CURL_PATH when `use_homebrew_curl` is `true`" do
expect(curl_executable(use_homebrew_curl: true)).to eq(HOMEBREW_BREWED_CURL_PATH) expect(curl_executable(use_homebrew_curl: true)).to eq(HOMEBREW_BREWED_CURL_PATH)
end end

View File

@ -170,7 +170,7 @@ module Homebrew
if Homebrew::EnvConfig.no_installed_dependents_check? if Homebrew::EnvConfig.no_installed_dependents_check?
unless Homebrew::EnvConfig.no_env_hints? unless Homebrew::EnvConfig.no_env_hints?
opoo <<~EOS opoo <<~EOS
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK is set: not checking for outdated `$HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set: not checking for outdated
dependents or dependents with broken linkage! dependents or dependents with broken linkage!
EOS EOS
end end
@ -418,8 +418,8 @@ module Homebrew
return if Homebrew::EnvConfig.no_installed_dependents_check? return if Homebrew::EnvConfig.no_installed_dependents_check?
return if @puts_no_installed_dependents_check_disable_message_if_not_already return if @puts_no_installed_dependents_check_disable_message_if_not_already
puts "Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK." puts "Disable this behaviour by setting `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1`."
puts "Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`)." puts "Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`)."
@puts_no_installed_dependents_check_disable_message_if_not_already = T.let(true, T.nilable(T::Boolean)) @puts_no_installed_dependents_check_disable_message_if_not_already = T.let(true, T.nilable(T::Boolean))
end end

View File

@ -899,7 +899,7 @@ module GitHub
end end
def self.count_repo_commits(nwo, user, from: nil, to: nil, max: nil) def self.count_repo_commits(nwo, user, from: nil, to: nil, max: nil)
odie "Cannot count commits, HOMEBREW_NO_GITHUB_API set!" if Homebrew::EnvConfig.no_github_api? odie "Cannot count commits as `$HOMEBREW_NO_GITHUB_API` is set!" if Homebrew::EnvConfig.no_github_api?
author_shas = repo_commits_for_user(nwo, user, "author", from, to, max) author_shas = repo_commits_for_user(nwo, user, "author", from, to, max)
committer_shas = repo_commits_for_user(nwo, user, "committer", from, to, max) committer_shas = repo_commits_for_user(nwo, user, "committer", from, to, max)
@ -922,7 +922,7 @@ module GitHub
# BrewTestBot can open as many PRs as it wants. # BrewTestBot can open as many PRs as it wants.
return false if ENV["HOMEBREW_TEST_BOT_AUTOBUMP"].present? return false if ENV["HOMEBREW_TEST_BOT_AUTOBUMP"].present?
odie "Cannot count PRs, HOMEBREW_NO_GITHUB_API set!" if Homebrew::EnvConfig.no_github_api? odie "Cannot count PRs as `$HOMEBREW_NO_GITHUB_API` is set!" if Homebrew::EnvConfig.no_github_api?
query = <<~EOS query = <<~EOS
query($after: String) { query($after: String) {

View File

@ -113,7 +113,7 @@ module GitHub
when :env_token when :env_token
require "utils/formatter" require "utils/formatter"
<<~EOS <<~EOS
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check: `$HOMEBREW_GITHUB_API_TOKEN` may be invalid or expired; check:
#{Formatter.url("https://github.com/settings/tokens")} #{Formatter.url("https://github.com/settings/tokens")}
EOS EOS
when :none when :none

View File

@ -693,7 +693,7 @@ __fish_brew_complete_arg 'desc; and not __fish_seen_argument -l formula -l formu
__fish_brew_complete_cmd 'determine-test-runners' 'Determines the runners used to test formulae or their dependents' __fish_brew_complete_cmd 'determine-test-runners' 'Determines the runners used to test formulae or their dependents'
__fish_brew_complete_arg 'determine-test-runners' -l all-supported -d 'Instead of selecting runners based on the chosen formula, return all supported runners' __fish_brew_complete_arg 'determine-test-runners' -l all-supported -d 'Instead of selecting runners based on the chosen formula, return all supported runners'
__fish_brew_complete_arg 'determine-test-runners' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'determine-test-runners' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'determine-test-runners' -l dependents -d 'Determine runners for testing dependents. Requires `--eval-all` or `$HOMEBREW_EVAL_ALL` to be set' __fish_brew_complete_arg 'determine-test-runners' -l dependents -d 'Determine runners for testing dependents. Requires `--eval-all` or `HOMEBREW_EVAL_ALL=1` to be set'
__fish_brew_complete_arg 'determine-test-runners' -l eval-all -d 'Evaluate all available formulae, whether installed or not, to determine testing dependents. Enabled by default if `$HOMEBREW_EVAL_ALL` is set' __fish_brew_complete_arg 'determine-test-runners' -l eval-all -d 'Evaluate all available formulae, whether installed or not, to determine testing dependents. Enabled by default if `$HOMEBREW_EVAL_ALL` is set'
__fish_brew_complete_arg 'determine-test-runners' -l help -d 'Show this message' __fish_brew_complete_arg 'determine-test-runners' -l help -d 'Show this message'
__fish_brew_complete_arg 'determine-test-runners' -l quiet -d 'Make some output more quiet' __fish_brew_complete_arg 'determine-test-runners' -l quiet -d 'Make some output more quiet'

View File

@ -875,7 +875,7 @@ _brew_determine_test_runners() {
_arguments \ _arguments \
'(--dependents)--all-supported[Instead of selecting runners based on the chosen formula, return all supported runners]' \ '(--dependents)--all-supported[Instead of selecting runners based on the chosen formula, return all supported runners]' \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'(--all-supported)--dependents[Determine runners for testing dependents. Requires `--eval-all` or `$HOMEBREW_EVAL_ALL` to be set]' \ '(--all-supported)--dependents[Determine runners for testing dependents. Requires `--eval-all` or `HOMEBREW_EVAL_ALL=1` to be set]' \
'--eval-all[Evaluate all available formulae, whether installed or not, to determine testing dependents. Enabled by default if `$HOMEBREW_EVAL_ALL` is set]' \ '--eval-all[Evaluate all available formulae, whether installed or not, to determine testing dependents. Enabled by default if `$HOMEBREW_EVAL_ALL` is set]' \
'--help[Show this message]' \ '--help[Show this message]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \