Exception: BuildError

Inherits:
RuntimeError
  • Object
show all
Defined in:
Library/Homebrew/exceptions.rb

Overview

Raised when an error occurs during a formula build.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BuildError.


391
392
393
394
395
396
397
398
# File 'Library/Homebrew/exceptions.rb', line 391

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args


388
389
390
# File 'Library/Homebrew/exceptions.rb', line 388

def args
  @args
end

#cmdObject (readonly)

Returns the value of attribute cmd


388
389
390
# File 'Library/Homebrew/exceptions.rb', line 388

def cmd
  @cmd
end

#envObject (readonly)

Returns the value of attribute env


388
389
390
# File 'Library/Homebrew/exceptions.rb', line 388

def env
  @env
end

#formulaObject

Returns the value of attribute formula


389
390
391
# File 'Library/Homebrew/exceptions.rb', line 389

def formula
  @formula
end

#optionsObject

Returns the value of attribute options


389
390
391
# File 'Library/Homebrew/exceptions.rb', line 389

def options
  @options
end

Instance Method Details

#dump(verbose: false) ⇒ Object


411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'Library/Homebrew/exceptions.rb', line 411

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 && defined?(OS::ISSUES_URL)
    if 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/brew or Homebrew/core):
          #{Formatter.url(issues_url)}
      EOS
    else
      puts <<~EOS
        If reporting this issue please do so to (not Homebrew/brew or Homebrew/core):
          #{formula.tap}
      EOS
    end
  else
    puts <<~EOS
      Do not report this issue to Homebrew/brew or Homebrew/core!
    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_issuesObject


404
405
406
407
408
409
# File 'Library/Homebrew/exceptions.rb', line 404

def fetch_issues
  GitHub.issues_for_formula(formula.name, tap: formula.tap, state: "open")
rescue GitHub::RateLimitExceededError => e
  opoo e.message
  []
end

#issuesObject


400
401
402
# File 'Library/Homebrew/exceptions.rb', line 400

def issues
  @issues ||= fetch_issues
end