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:



499
500
501
502
503
504
505
506
# File 'exceptions.rb', line 499

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

Instance Attribute Details

#argsObject (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.



488
489
490
# File 'exceptions.rb', line 488

def args
  @args
end

#cmdObject (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.



488
489
490
# File 'exceptions.rb', line 488

def cmd
  @cmd
end

#envObject (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.



488
489
490
# File 'exceptions.rb', line 488

def env
  @env
end

#formulaObject

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.



489
490
491
# File 'exceptions.rb', line 489

def formula
  @formula
end

#optionsObject

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.



489
490
491
# File 'exceptions.rb', line 489

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)


524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'exceptions.rb', line 524

def dump(verbose: false)
  puts

  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

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



514
515
516
517
518
519
520
521
# File 'exceptions.rb', line 514

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

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



509
510
511
# File 'exceptions.rb', line 509

def issues
  @issues ||= fetch_issues
end