Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions bundler/lib/bundler/cli/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ def get_console(name)
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)
Expand All @@ -32,9 +37,6 @@ def get_constant(name)
"irb" => :IRB,
}[name]
Object.const_get(const_name)
rescue NameError
Bundler.ui.error "Could not find constant #{const_name}"
exit 1
end
end
end
11 changes: 11 additions & 0 deletions bundler/spec/commands/console_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ def __pry__
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")
Expand Down
Loading