Exception: FormulaConflictError

Inherits:
RuntimeError
  • Object
show all
Extended by:
T::Sig
Defined in:
exceptions.rb

Overview

Raised when a formula conflicts with another one.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula, conflicts) ⇒ FormulaConflictError

Returns a new instance of FormulaConflictError.



369
370
371
372
373
# File 'exceptions.rb', line 369

def initialize(formula, conflicts)
  @formula = formula
  @conflicts = conflicts
  super message
end

Instance Attribute Details

#conflictsObject (readonly)

Returns the value of attribute conflicts.



367
368
369
# File 'exceptions.rb', line 367

def conflicts
  @conflicts
end

#formulaObject (readonly)

Returns the value of attribute formula.



367
368
369
# File 'exceptions.rb', line 367

def formula
  @formula
end

Instance Method Details

#conflict_message(conflict) ⇒ Object



375
376
377
378
379
380
# File 'exceptions.rb', line 375

def conflict_message(conflict)
  message = []
  message << "  #{conflict.name}"
  message << ": because #{conflict.reason}" if conflict.reason
  message.join
end

#messageString

Returns:



383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'exceptions.rb', line 383

def message
  message = []
  message << "Cannot install #{formula.full_name} because conflicting formulae are installed."
  message.concat conflicts.map { |c| conflict_message(c) } << ""
  message << <<~EOS
    Please `brew unlink #{conflicts.map(&:name) * " "}` before continuing.

    Unlinking removes a formula's symlinks from #{HOMEBREW_PREFIX}. You can
    link the formula again after the install finishes. You can --force this
    install, but the build may fail or cause obscure side effects in the
    resulting software.
  EOS
  message.join("\n")
end