diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-04-13 12:13:59 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | 1663dd5f73c514343937cc018f5371dbffdeed99 (patch) | |
tree | 21c9956ba12f8947ccb09d91c70832335f00088b | |
parent | 0aa9eb9eed9e0cb38c7e1c1fcd37061bdfc385b7 (diff) | |
download | ruby-1663dd5f73c514343937cc018f5371dbffdeed99.tar.gz |
[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
-rw-r--r-- | lib/rubygems.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index a7d378e2d3..2f8c73972f 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1109,21 +1109,22 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path) require 'rubygems/user_interaction' - Gem::DefaultUserInteraction.use_ui(ui) do - require "bundler" - begin - Bundler.ui.silence do - @gemdeps = Bundler.setup + require "bundler" + begin + Gem::DefaultUserInteraction.use_ui(ui) do + begin + Bundler.ui.silence do + @gemdeps = Bundler.setup + end + ensure + Gem::DefaultUserInteraction.ui.close end - ensure - Gem::DefaultUserInteraction.ui.close end + rescue Bundler::BundlerError => e + warn e.message + warn "You may need to `gem install -g` to install missing gems" + warn "" 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 ## |