Skip to content

Commit 56e2ef2

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Fix bundle console unnecessarily trying to load IRB twice
ruby/rubygems@f9bf58573f
1 parent 3cff46c commit 56e2ef2

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/bundler/cli/console.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ def get_console(name)
2020
require name
2121
get_constant(name)
2222
rescue LoadError
23-
Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
24-
require "irb"
25-
get_constant("irb")
23+
if name == "irb"
24+
Bundler.ui.error "#{name} is not available"
25+
exit 1
26+
else
27+
Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
28+
name = "irb"
29+
retry
30+
end
2631
end
2732

2833
def get_constant(name)

spec/bundler/commands/console_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ def __pry__
119119
expect(out).to include("(irb)")
120120
end
121121

122+
it "does not try IRB twice if no console is configured and IRB is not available" do
123+
create_file("irb.rb", "raise LoadError, 'irb is not available'")
124+
125+
bundle("console", env: { "RUBYOPT" => "-I#{bundled_app} #{ENV["RUBYOPT"]}" }, raise_on_error: false) do |input, _, _|
126+
input.puts("puts ACTIVESUPPORT")
127+
input.puts("exit")
128+
end
129+
expect(err).not_to include("falling back to irb")
130+
expect(err).to include("irb is not available")
131+
end
132+
122133
it "doesn't load any other groups" do
123134
bundle "console" do |input, _, _|
124135
input.puts("puts ACTIVESUPPORT")

0 commit comments

Comments
 (0)