Class: Homebrew::Cmd::Bundle::CheckSubcommand Private

Inherits:
AbstractSubcommand show all
Defined in:
bundle/subcommand/check.rb

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

Instance Attribute Summary

Attributes inherited from AbstractSubcommand

#args, #cleanup, #context, #quiet, #targets

Instance Method Summary collapse

Methods inherited from AbstractSubcommand

define, define_all, #initialize, subcommand_name, subcommands_for

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable

Constructor Details

This class inherits a constructor from Homebrew::AbstractSubcommand

Instance Method Details

#runvoid

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.

This method returns an undefined value.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'bundle/subcommand/check.rb', line 32

def run
  output_errors = context.verbose
  exit_on_first_error = !context.verbose
  check_result = Homebrew::Bundle::Checker.check(
    global: context.global, file: context.file,
    exit_on_first_error:, no_upgrade: context.no_upgrade, verbose: context.verbose
  )

  # Allow callers of `brew bundle check` to specify when they've already
  # output some formulae errors.
  check_missing_formulae = ENV.fetch("HOMEBREW_BUNDLE_CHECK_ALREADY_OUTPUT_FORMULAE_ERRORS", "")
                              .strip
                              .split

  if check_result.work_to_be_done
    puts "brew bundle can't satisfy your Brewfile's dependencies." if check_missing_formulae.blank?

    if output_errors
      check_result.errors.each do |error|
        if (match = error.match(/^Formula (.+) needs to be installed/)) &&
           check_missing_formulae.include?(match[1])
          next
        end

        puts "#{error}"
      end
    else
      puts "Run `brew bundle check --verbose` to list unmet dependencies."
    end

    puts "Satisfy missing dependencies with `brew bundle install`."
    exit 1
  end

  puts "The Brewfile's dependencies are satisfied." unless quiet
end