Skip to content

Commit f7b9ed1

Browse files
committed
Make some global variables part of the public API
These are all useful to be able to tell users to rely on them and we've used them long enough for it to make sense as a public API. Relatedly, these are all used in at least some Homebrew/homebrew-core or Homebrew/homebrew-cask formulae. While we're here, update the descriptions to be a bit more user friendly.
1 parent e5406f7 commit f7b9ed1

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

Library/Homebrew/.rubocop.yml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Style/Documentation:
6565
- livecheck/strategy/yaml.rb
6666
- os.rb
6767
- resource.rb
68+
- startup/config.rb
6869
- utils/inreplace.rb
6970
- utils/shebang.rb
7071
- utils/string_inreplace_extension.rb

Library/Homebrew/startup/config.rb

+29-19
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,39 @@
33

44
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
55

6-
# Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
7-
# Used for e.g. permissions checks.
8-
HOMEBREW_ORIGINAL_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_ORIGINAL_BREW_FILE")).freeze
9-
10-
# Path to the executable that should be used to run `brew`.
11-
# This may be HOMEBREW_ORIGINAL_BREW_FILE or HOMEBREW_BREW_WRAPPER.
6+
# The path to the executable that should be used to run `brew`.
7+
# This may be HOMEBREW_ORIGINAL_BREW_FILE or HOMEBREW_BREW_WRAPPER depending on
8+
# the system configuration. Favour this instead of running `brew` and expecting
9+
# it to be in the `PATH`.
10+
# @api public
1211
HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze
1312

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

17+
# Where Homebrew stores built formulae packages, linking (non-keg-only) ones
18+
# back to `HOMEBREW_PREFIX`.
19+
# @api public
20+
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze
21+
22+
# Where Homebrew downloads (bottles, source tarballs, casks etc.) are cached.
23+
# @api public
24+
HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze
25+
26+
# Where Homebrew stores temporary files.
27+
# We use `/tmp` instead of `TMPDIR` because long paths break Unix domain
28+
# sockets.
29+
# @api public
30+
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
31+
tmp.mkpath unless tmp.exist?
32+
tmp.realpath
33+
end.freeze
34+
35+
# Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
36+
# Used for e.g. permissions checks.
37+
HOMEBREW_ORIGINAL_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_ORIGINAL_BREW_FILE")).freeze
38+
1739
# Where `.git` is found
1840
HOMEBREW_REPOSITORY = Pathname(ENV.fetch("HOMEBREW_REPOSITORY")).freeze
1941

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

38-
# Where we store built products
39-
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze
40-
4160
# Where we store Casks
4261
HOMEBREW_CASKROOM = Pathname(ENV.fetch("HOMEBREW_CASKROOM")).freeze
4362

44-
# Where downloads (bottles, source tarballs, etc.) are cached
45-
HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze
46-
4763
# Where formulae installed via URL are cached
4864
HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
4965

5066
# Where build, postinstall and test logs of formulae are written to
5167
HOMEBREW_LOGS = Pathname(ENV.fetch("HOMEBREW_LOGS")).expand_path.freeze
5268

53-
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
54-
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
55-
tmp.mkpath unless tmp.exist?
56-
tmp.realpath
57-
end.freeze
58-
5969
# Where installed taps live
6070
HOMEBREW_TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze
6171

0 commit comments

Comments
 (0)