Remove missing env retry mechanism

This commit is contained in:
Bo Anderson 2022-05-30 04:05:07 +01:00
parent 1e52f08f49
commit db8ab91429
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 9 additions and 39 deletions

View File

@ -22,24 +22,7 @@ if RUBY_X < REQUIRED_RUBY_X || (RUBY_X == REQUIRED_RUBY_X && RUBY_Y < REQUIRED_R
"You're running #{RUBY_VERSION}." "You're running #{RUBY_VERSION}."
end end
# Also define here so we can rescue regardless of location. require_relative "global"
class MissingEnvironmentVariables < RuntimeError; end
begin
require_relative "global"
rescue MissingEnvironmentVariables => e
raise e if ENV["HOMEBREW_MISSING_ENV_RETRY"]
if ENV["HOMEBREW_DEVELOPER"]
$stderr.puts <<~EOS
Warning: #{e.message}
Retrying with `exec #{ENV["HOMEBREW_BREW_FILE"]}`!
EOS
end
ENV["HOMEBREW_MISSING_ENV_RETRY"] = "1"
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
end
begin begin
trap("INT", std_trap) # restore default CTRL-C handler trap("INT", std_trap) # restore default CTRL-C handler

View File

@ -4,29 +4,16 @@
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
# Path to `bin/brew` main executable in `HOMEBREW_PREFIX` # Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
HOMEBREW_BREW_FILE = Pathname(ENV["HOMEBREW_BREW_FILE"]).freeze HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze
class MissingEnvironmentVariables < RuntimeError; end
# Helper module for getting environment variables which must be set.
#
# @api private
module EnvVar
def self.[](env)
raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env]
ENV.fetch(env)
end
end
# Where we link under # Where we link under
HOMEBREW_PREFIX = Pathname(EnvVar["HOMEBREW_PREFIX"]).freeze HOMEBREW_PREFIX = Pathname(ENV.fetch("HOMEBREW_PREFIX")).freeze
# Where `.git` is found # Where `.git` is found
HOMEBREW_REPOSITORY = Pathname(EnvVar["HOMEBREW_REPOSITORY"]).freeze HOMEBREW_REPOSITORY = Pathname(ENV.fetch("HOMEBREW_REPOSITORY")).freeze
# Where we store most of Homebrew, taps, and various metadata # Where we store most of Homebrew, taps, and various metadata
HOMEBREW_LIBRARY = Pathname(EnvVar["HOMEBREW_LIBRARY"]).freeze HOMEBREW_LIBRARY = Pathname(ENV.fetch("HOMEBREW_LIBRARY")).freeze
# Where shim scripts for various build and SCM tools are stored # Where shim scripts for various build and SCM tools are stored
HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY/"Homebrew/shims").freeze HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY/"Homebrew/shims").freeze
@ -44,19 +31,19 @@ HOMEBREW_PINNED_KEGS = (HOMEBREW_PREFIX/"var/homebrew/pinned").freeze
HOMEBREW_LOCKS = (HOMEBREW_PREFIX/"var/homebrew/locks").freeze HOMEBREW_LOCKS = (HOMEBREW_PREFIX/"var/homebrew/locks").freeze
# Where we store built products # Where we store built products
HOMEBREW_CELLAR = Pathname(EnvVar["HOMEBREW_CELLAR"]).freeze HOMEBREW_CELLAR = Pathname(ENV.fetch("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(ENV.fetch("HOMEBREW_CACHE")).freeze
# Where formulae 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
HOMEBREW_LOGS = Pathname(EnvVar["HOMEBREW_LOGS"]).expand_path.freeze HOMEBREW_LOGS = Pathname(ENV.fetch("HOMEBREW_LOGS")).expand_path.freeze
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets # Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
HOMEBREW_TEMP = Pathname(EnvVar["HOMEBREW_TEMP"]).then do |tmp| HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
tmp.mkpath unless tmp.exist? tmp.mkpath unless tmp.exist?
tmp.realpath tmp.realpath
end.freeze end.freeze