1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Simplify rescue of bundler errors

As far as I understand, this block should only be run when
`bundler/setup` fails. The only other case where these errors could be
run is when bundler itself is required.

If bundler itself fails to be required or activated (like in old rubies
where it was not a default gem, for example), the raw error is much more
helpful than this message.

So we can move the rescue after bundler is succesfully required, and
that simplifies the list of exceptions that we need to track to just
`Bundler::Error`.

https://github.com/rubygems/rubygems/commit/3663c11e93
This commit is contained in:
David Rodríguez 2021-04-13 12:13:59 +02:00 committed by Hiroshi SHIBATA
parent 0aa9eb9eed
commit 1663dd5f73
Notes: git 2021-08-31 19:07:14 +09:00

View file

@ -1109,21 +1109,22 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path) ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
require 'rubygems/user_interaction' require 'rubygems/user_interaction'
Gem::DefaultUserInteraction.use_ui(ui) do require "bundler"
require "bundler" begin
begin Gem::DefaultUserInteraction.use_ui(ui) do
Bundler.ui.silence do begin
@gemdeps = Bundler.setup Bundler.ui.silence do
@gemdeps = Bundler.setup
end
ensure
Gem::DefaultUserInteraction.ui.close
end end
ensure
Gem::DefaultUserInteraction.ui.close
end end
rescue Bundler::BundlerError => e
warn e.message
warn "You may need to `gem install -g` to install missing gems"
warn ""
end end
rescue Gem::LoadError, Gem::UnsatisfiableDependencyError, (defined?(Bundler::GemNotFound) ? Bundler::GemNotFound : Gem::LoadError) => e
warn e.message
warn "You may need to `gem install -g` to install missing gems"
warn ""
end end
## ##