summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-01-27 20:08:56 +0100
committerHiroshi SHIBATA <[email protected]>2025-01-31 14:34:29 +0900
commit56e2ef24680424fd9392ad82a9cc852d9549b942 (patch)
treee4bf94c242f5cdd7c196c384af57e46eba71fb4b
parent3cff46c521668a67572ee1ed7ae23de2fd39fddd (diff)
[rubygems/rubygems] Fix `bundle console` unnecessarily trying to load IRB twice
https://github.com/rubygems/rubygems/commit/f9bf58573f
-rw-r--r--lib/bundler/cli/console.rb11
-rw-r--r--spec/bundler/commands/console_spec.rb11
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb
index a93c750b22..f6389e8ea0 100644
--- a/lib/bundler/cli/console.rb
+++ b/lib/bundler/cli/console.rb
@@ -20,9 +20,14 @@ module Bundler
require name
get_constant(name)
rescue LoadError
- Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
- require "irb"
- get_constant("irb")
+ if name == "irb"
+ Bundler.ui.error "#{name} is not available"
+ exit 1
+ else
+ Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
+ name = "irb"
+ retry
+ end
end
def get_constant(name)
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
index ecb4877b3a..fbeec8fe55 100644
--- a/spec/bundler/commands/console_spec.rb
+++ b/spec/bundler/commands/console_spec.rb
@@ -119,6 +119,17 @@ RSpec.describe "bundle console", readline: true do
expect(out).to include("(irb)")
end
+ it "does not try IRB twice if no console is configured and IRB is not available" do
+ create_file("irb.rb", "raise LoadError, 'irb is not available'")
+
+ bundle("console", env: { "RUBYOPT" => "-I#{bundled_app} #{ENV["RUBYOPT"]}" }, raise_on_error: false) do |input, _, _|
+ input.puts("puts ACTIVESUPPORT")
+ input.puts("exit")
+ end
+ expect(err).not_to include("falling back to irb")
+ expect(err).to include("irb is not available")
+ end
+
it "doesn't load any other groups" do
bundle "console" do |input, _, _|
input.puts("puts ACTIVESUPPORT")