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

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

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:



623
624
625
626
627
628
629
630
631
# File 'exceptions.rb', line 623

def initialize(formula, cmd, args, env)
  @formula = formula
  @cmd = cmd
  @args = args
  @env = env
  @options = T.let(nil, T.nilable(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

#argsArray<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:



603
604
605
# File 'exceptions.rb', line 603

def args
  @args
end

#cmdString, ... (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:



600
601
602
# File 'exceptions.rb', line 600

def cmd
  @cmd
end

#envHash{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:



606
607
608
# File 'exceptions.rb', line 606

def env
  @env
end

#formulaFormula?

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 formula
  @formula
end

#optionsArray<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:



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

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)


652
653
654
655
656
657
658
659
660
661
662
663
664
665
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
713
714
715
716
717
718
719
720
721
# File 'exceptions.rb', line 652

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

  formula_tap = formula.tap
  if formula_tap
    if OS.not_tier_one_configuration?
      <<~EOS
        This is not a Tier 1 configuration:
          #{Formatter.url("https://docs.brew.sh/Support-Tiers")}
        #{Formatter.bold("Do not report any issues to Homebrew/* repositories!")}
        Read the above document instead before opening any issues or PRs.
      EOS
    elsif formula_tap.official?
      puts Formatter.error(Formatter.url(OS::ISSUES_URL), label: "READ THIS")
    elsif (issues_url = formula_tap.issues_url)
      puts <<~EOS
        If reporting this issue please do so at (not Homebrew/* repositories):
          #{Formatter.url(issues_url)}
      EOS
    else
      puts <<~EOS
        If reporting this issue please do so to (not Homebrew/* repositories):
          #{formula_tap}
      EOS
    end
  else
    <<~EOS
      We cannot detect the correct tap to report this issue to.
      Do not report this issue to Homebrew/* repositories!
    EOS
  end

  puts

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

  require "diagnostic"
  checks = Homebrew::Diagnostic::Checks.new
  checks.build_error_checks.each do |check|
    out = checks.send(check)
    next if out.nil?

    puts
    ofail out
  end
end

#fetch_issuesArray<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:



639
640
641
642
643
644
645
646
647
648
649
# File 'exceptions.rb', line 639

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

#issuesArray<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:



634
635
636
# File 'exceptions.rb', line 634

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