Module: Utils::Executable Private

Defined in:
utils/executable.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.ensure!(name, formula_name = nil, reason: "", latest: false) ⇒ Pathname

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • formula_name (String, nil) (defaults to: nil)
  • reason (String) (defaults to: "")
  • latest (Boolean) (defaults to: false)

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'utils/executable.rb', line 11

def ensure!(name, formula_name = nil, reason: "", latest: false)
  formula_name ||= name

  executable = [
    Utils::Shell.which(name),
    Utils::Shell.which(name, ORIGINAL_PATHS),
    HOMEBREW_PREFIX/"opt/#{formula_name}/bin/#{name}",
    HOMEBREW_PREFIX/"bin/#{name}",
  ].compact.find(&:exist?)
  return executable if executable

  Kernel.require "formula"
  T.cast(Formula[formula_name].ensure_installed!(reason:, latest:, executable: name), Pathname)
end