@@ -57,12 +57,14 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
5757
5858 # Choose a readline library before calling the parent
5959 rl_err = nil
60- if ( opts [ 'RealReadline' ] )
60+ if opts [ 'RealReadline' ]
6161 # Remove the gem version from load path to be sure we're getting the
6262 # stdlib readline.
6363 gem_dir = Gem ::Specification . find_all_by_name ( 'rb-readline' ) . first . gem_dir
6464 rb_readline_path = File . join ( gem_dir , "lib" )
6565 index = $LOAD_PATH. index ( rb_readline_path )
66+ # Bundler guarantees that the gem will be there, so it should be safe to
67+ # assume we found it in the load path, but check to be on the safe side.
6668 if index
6769 $LOAD_PATH. delete_at ( index )
6870 end
@@ -71,15 +73,17 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
7173 begin
7274 require 'readline'
7375 rescue ::LoadError => e
74- if rl_err . nil? && rb_readline_path && index
76+ if rl_err . nil? && index
77+ # Then this is the first time the require failed and we have an index
78+ # for the gem version as a fallback.
7579 rl_err = e
7680 # Put the gem back and see if that works
7781 $LOAD_PATH. insert ( index , rb_readline_path )
7882 index = rb_readline_path = nil
7983 retry
8084 else
81- # Either didn't have the gem to fall back on, or we failed twice.
82- # Nothing more to do here.
85+ # Either we didn't have the gem to fall back on, or we failed twice.
86+ # Nothing more we can do here.
8387 raise e
8488 end
8589 end
0 commit comments