Exception: BuildError Private

Inherits:
RuntimeError
  • Object
show all
Includes:
Utils::Output::Mixin
Defined in:
exceptions.rb

Overview

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.

Raised when an error occurs during a formula build.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

#initialize(formula, cmd, args, env) ⇒ void

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:



636
637
638
639
640
641
642
643
644
645
# File 'exceptions.rb', line 636

def initialize(formula, cmd, args, env)
  @formula = formula
  @cmd = cmd
  @args = args
  @env = env
  @options = T.let(nil, T.nilable(T::Array[String]))
  @build_flags = T.let([], T::Array[String])
  pretty_args = Array(args).map { |arg| arg.to_s.gsub(/[\\ ]/, "\\\\\\0") }.join(" ")
  super "Failed executing: #{cmd} #{pretty_args}".strip
end

Instance Attribute Details

#args ⇒ Array<String, Integer, Pathname, Symbol, Array<String>, Hash{String => String, nil}, nil> (readonly)

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.

Returns:



612
613
614
# File 'exceptions.rb', line 612

def args
  @args
end

#build_flags ⇒ Array<String>

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.

Flags for this particular build, including the compiler and source selection.

Returns:



625
626
627
# File 'exceptions.rb', line 625

def build_flags
  @build_flags
end

#cmd ⇒ String, ... (readonly)

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.

Returns:



609
610
611
# File 'exceptions.rb', line 609

def cmd
  @cmd
end

#env ⇒ Hash{String => String, Boolean, PATH, nil} (readonly)

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.

Returns:



615
616
617
# File 'exceptions.rb', line 615

def env
  @env
end

#formula ⇒ Formula?

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.

Returns:



618
619
620
# File 'exceptions.rb', line 618

def formula
  @formula
end

#options ⇒ Array<String>?

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.

Returns:



621
622
623
# File 'exceptions.rb', line 621

def options
  @options
end

Instance Method Details

#dump(verbose: false) ⇒ void

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.

Parameters:

  • verbose (Boolean) (defaults to: false)


666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'exceptions.rb', line 666

def dump(verbose: false)
  puts
  formula = self.formula
  return unless formula

  if verbose
    require "system_config"
    require "build_environment"

    ohai "Formula"
    puts "Tap: #{formula.tap}" if formula.tap?
    puts "Path: #{formula.path}"
    ohai "Configuration"
    SystemConfig.dump_verbose_config
    ohai "ENV"
    BuildEnvironment.dump env
    puts
    onoe "#{formula.full_name} #{formula.version} did not build"
    unless (logs = Dir["#{formula.logs}/*"]).empty?
      puts "Logs:"
      puts logs.map { |fn| "     #{fn}" }.join("\n")
    end
  end

  require "diagnostic"
  tiers = Homebrew::Diagnostic.checks(:build_error_checks, fatal: false)
  if (finding = Homebrew::Diagnostic.formula_build_finding(formula, build_options: build_flags))
    $stderr.puts finding.text, "This build failure is expected behaviour."
    tiers << finding.tier
    Homebrew::Diagnostic.support_tiers << finding.tier
  end

  tier = Homebrew::Diagnostic::Finding.support_tier(tiers)
  if (guidance = issue_reporting_message(tier:))
    puts guidance
    return
  end

  if (tap = formula.tap)
    puts issue_reporting_message(tap.official? ? :homebrew : tap, tier:), ""
  end

  return unless issues.present?

  puts "These open issues may also help:"
  puts issues.map { |i| "#{i["title"]} #{i["html_url"]}" }.join("\n")
end

#fetch_issues ⇒ Array<Hash{String => T.untyped}>

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.

Returns:



653
654
655
656
657
658
659
660
661
662
663
# File 'exceptions.rb', line 653

def fetch_issues
  return [] if ENV["HOMEBREW_NO_BUILD_ERROR_ISSUES"].present?

  formula = self.formula
  return [] unless formula

  GitHub.issues_for_formula(formula.name, tap: formula.tap, state: "open", type: "issue")
rescue GitHub::API::Error => e
  opoo "Unable to query GitHub for recent issues on the tap\n#{e.message}"
  []
end

#issues ⇒ Array<Hash{String => T.untyped}>

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.

Returns:



648
649
650
# File 'exceptions.rb', line 648

def issues
  @issues ||= T.let(fetch_issues, T.nilable(T::Array[T::Hash[String, T.untyped]]))
end