Work around Readline clash

Only limited debugging functionality is available to things that involve
the Readline formula, but it is better than crashing outright.

c.f. Homebrew/homebrew#15776.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-11-11 18:07:03 -06:00
parent 6136c3c5d1
commit efcd926d1b
2 changed files with 14 additions and 7 deletions

View File

@ -1,9 +1,10 @@
require 'irb' def can_use_readline?
begin not ENV['HOMEBREW_NO_READLINE']
require 'continuation' # needed on 1.9
rescue LoadError
end end
require 'irb' if can_use_readline?
require 'continuation' if RUBY_VERSION.to_f >= 1.9
class Menu class Menu
attr_accessor :prompt attr_accessor :prompt
attr_accessor :entries attr_accessor :entries
@ -75,7 +76,7 @@ module IRB
irb_at_exit irb_at_exit
end end
end end
end end if can_use_readline?
class Exception class Exception
attr_accessor :continuation attr_accessor :continuation
@ -92,7 +93,7 @@ def has_debugger?
true true
rescue LoadError rescue LoadError
false false
end end if can_use_readline?
end end
def debrew(exception, formula=nil) def debrew(exception, formula=nil)
@ -121,7 +122,7 @@ def debrew(exception, formula=nil)
end end
} }
end end
end end if can_use_readline?
menu.choice(:shell) do menu.choice(:shell) do
puts "When you exit this shell, you will return to the menu." puts "When you exit this shell, you will return to the menu."
interactive_shell formula interactive_shell formula

View File

@ -73,6 +73,12 @@ class FormulaInstaller
needed_deps = [] needed_deps = []
needed_reqs = [] needed_reqs = []
# HACK: If readline is present in the dependency tree, it will clash
# with the stdlib's Readline module when the debugger is loaded
if f.recursive_deps.any? { |d| d.name == "readline" } and ARGV.debug?
ENV['HOMEBREW_NO_READLINE'] = '1'
end
ARGV.filter_for_dependencies do ARGV.filter_for_dependencies do
needed_deps = f.recursive_deps.reject{ |d| d.installed? } needed_deps = f.recursive_deps.reject{ |d| d.installed? }
needed_reqs = f.recursive_requirements.reject { |r| r.satisfied? } needed_reqs = f.recursive_requirements.reject { |r| r.satisfied? }