diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 290b7a3db8..ab1a31e3b1 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -22,24 +22,7 @@ if RUBY_X < REQUIRED_RUBY_X || (RUBY_X == REQUIRED_RUBY_X && RUBY_Y < REQUIRED_R "You're running #{RUBY_VERSION}." end -# Also define here so we can rescue regardless of location. -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 +require_relative "global" begin trap("INT", std_trap) # restore default CTRL-C handler diff --git a/Library/Homebrew/startup/config.rb b/Library/Homebrew/startup/config.rb index 26470cc464..0439e8ab03 100644 --- a/Library/Homebrew/startup/config.rb +++ b/Library/Homebrew/startup/config.rb @@ -4,29 +4,16 @@ 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` -HOMEBREW_BREW_FILE = Pathname(ENV["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 +HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze # Where we link under -HOMEBREW_PREFIX = Pathname(EnvVar["HOMEBREW_PREFIX"]).freeze +HOMEBREW_PREFIX = Pathname(ENV.fetch("HOMEBREW_PREFIX")).freeze # 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 -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 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 # 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 -HOMEBREW_CACHE = Pathname(EnvVar["HOMEBREW_CACHE"]).freeze +HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze # Where formulae installed via URL are cached HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze # 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 -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.realpath end.freeze