summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-01-24 16:22:42 +0100
committerHiroshi SHIBATA <[email protected]>2025-01-28 15:31:55 +0900
commit7ae6aa0efccc486da6c7c32f7d06bff6e4770870 (patch)
tree324062dc768f2e66809ffc64f59bc5658ff475d6
parentd157aa7a9774c3725f3043fda408582ba2b09531 (diff)
[rubygems/rubygems] Handle all `Bundle.require` exceptions at the same level
https://github.com/rubygems/rubygems/commit/a5519f4f79
-rw-r--r--lib/bundler/runtime.rb46
1 files changed, 22 insertions, 24 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index a9b3ed9a99..e349901df4 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -53,31 +53,29 @@ module Bundler
required_file = nil
Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)
- begin
- # Loop through all the specified autorequires for the
- # dependency. If there are none, use the dependency's name
- # as the autorequire.
- Array(dep.autorequire || dep.name).each do |file|
- # Allow `require: true` as an alias for `require: <name>`
- file = dep.name if file == true
- required_file = file
- begin
- Kernel.require file
- rescue RuntimeError => e
- raise Bundler::GemRequireError.new e,
- "There was an error while trying to load the gem '#{file}'."
- end
- end
- rescue LoadError => e
- raise if dep.autorequire || e.path != required_file
-
- if dep.autorequire.nil? && dep.name.include?("-")
- begin
- namespaced_file = dep.name.tr("-", "/")
- Kernel.require namespaced_file
- rescue LoadError => e
- raise if e.path != namespaced_file
+ # Loop through all the specified autorequires for the
+ # dependency. If there are none, use the dependency's name
+ # as the autorequire.
+ Array(dep.autorequire || dep.name).each do |file|
+ # Allow `require: true` as an alias for `require: <name>`
+ file = dep.name if file == true
+ required_file = file
+ begin
+ Kernel.require file
+ rescue LoadError => e
+ raise if dep.autorequire || e.path != required_file
+
+ if dep.autorequire.nil? && dep.name.include?("-")
+ begin
+ namespaced_file = dep.name.tr("-", "/")
+ Kernel.require namespaced_file
+ rescue LoadError => e
+ raise if e.path != namespaced_file
+ end
end
+ rescue RuntimeError => e
+ raise Bundler::GemRequireError.new e,
+ "There was an error while trying to load the gem '#{file}'."
end
end