Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some global variables part of the public API #19569

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Style/Documentation:
- livecheck/strategy/yaml.rb
- os.rb
- resource.rb
- startup/config.rb
- utils/inreplace.rb
- utils/shebang.rb
- utils/string_inreplace_extension.rb
Expand Down
48 changes: 29 additions & 19 deletions Library/Homebrew/startup/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,39 @@

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`
# Used for e.g. permissions checks.
HOMEBREW_ORIGINAL_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_ORIGINAL_BREW_FILE")).freeze

# Path to the executable that should be used to run `brew`.
# This may be HOMEBREW_ORIGINAL_BREW_FILE or HOMEBREW_BREW_WRAPPER.
# The path to the executable that should be used to run `brew`.
# This may be HOMEBREW_ORIGINAL_BREW_FILE or HOMEBREW_BREW_WRAPPER depending on
# the system configuration. Favour this instead of running `brew` and expecting
# it to be in the `PATH`.
# @api public
HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze

# Where we link under
# Where Homebrew is installed and files are linked to.
# @api public
HOMEBREW_PREFIX = Pathname(ENV.fetch("HOMEBREW_PREFIX")).freeze

# Where Homebrew stores built formulae packages, linking (non-keg-only) ones
# back to `HOMEBREW_PREFIX`.
# @api public
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze

Check warning on line 20 in Library/Homebrew/startup/config.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/config.rb#L20

Added line #L20 was not covered by tests

# Where Homebrew downloads (bottles, source tarballs, casks etc.) are cached.
# @api public
HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze

Check warning on line 24 in Library/Homebrew/startup/config.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/config.rb#L24

Added line #L24 was not covered by tests

# Where Homebrew stores temporary files.
# We use `/tmp` instead of `TMPDIR` because long paths break Unix domain
# sockets.
# @api public
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
tmp.mkpath unless tmp.exist?
tmp.realpath
end.freeze

Check warning on line 33 in Library/Homebrew/startup/config.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/config.rb#L30-L33

Added lines #L30 - L33 were not covered by tests

# Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
# Used for e.g. permissions checks.
HOMEBREW_ORIGINAL_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_ORIGINAL_BREW_FILE")).freeze

Check warning on line 37 in Library/Homebrew/startup/config.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/config.rb#L37

Added line #L37 was not covered by tests

# Where `.git` is found
HOMEBREW_REPOSITORY = Pathname(ENV.fetch("HOMEBREW_REPOSITORY")).freeze

Expand All @@ -35,27 +57,15 @@
# Where we store lock files
HOMEBREW_LOCKS = (HOMEBREW_PREFIX/"var/homebrew/locks").freeze

# Where we store built products
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze

# Where we store Casks
HOMEBREW_CASKROOM = Pathname(ENV.fetch("HOMEBREW_CASKROOM")).freeze

# Where downloads (bottles, source tarballs, etc.) are cached
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(ENV.fetch("HOMEBREW_LOGS")).expand_path.freeze

# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
tmp.mkpath unless tmp.exist?
tmp.realpath
end.freeze

# Where installed taps live
HOMEBREW_TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze

Expand Down
Loading