Exception: FormulaConflictError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula, conflicts) ⇒ FormulaConflictError

Returns a new instance of FormulaConflictError



317
318
319
320
321
# File 'brew/Library/Homebrew/exceptions.rb', line 317

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

Instance Attribute Details

#conflictsObject (readonly)

Returns the value of attribute conflicts



315
316
317
# File 'brew/Library/Homebrew/exceptions.rb', line 315

def conflicts
  @conflicts
end

#formulaObject (readonly)

Returns the value of attribute formula



315
316
317
# File 'brew/Library/Homebrew/exceptions.rb', line 315

def formula
  @formula
end

Instance Method Details

#conflict_message(conflict) ⇒ Object



323
324
325
326
327
328
# File 'brew/Library/Homebrew/exceptions.rb', line 323

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

#messageObject



330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'brew/Library/Homebrew/exceptions.rb', line 330

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