summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-11-12 19:34:10 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-11-13 13:47:36 +0900
commit441069c093ab0d21efff1f0f3144fdf412f9f675 (patch)
tree399501adfeb5978a98917db191d62c4c73661ee0
parent8ae63ca3beb0db779b13ffa8690584a8144262c3 (diff)
We can't handle optional dependency without new API of Rubygems.
I don't want to make bundled_gems.rb more complex and complicate. Revert "Fixed warning condition with LoadError" This reverts commit 3a9e48b9a4860022f43d8101c0f3249299437886. Revert "Only warn fiddle as optional dependency" This reverts commit ff3f61556fb62d12d57d017f4c54f1a8fd5208be. Revert "Only `warn` about bundled gems when require succeeds" This reverts commit a70adce1ce5fae8eaae385214ac0d2e7d17c1103.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12072
-rw-r--r--lib/bundled_gems.rb23
1 files changed, 2 insertions, 21 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
index 38057cf6c5..ed7b8e278a 100644
--- a/lib/bundled_gems.rb
+++ b/lib/bundled_gems.rb
@@ -49,10 +49,6 @@ module Gem::BUNDLED_GEMS
"syslog" => true,
}.freeze
- OPTIONAL = {
- "fiddle" => true,
- }.freeze
-
WARNED = {} # unfrozen
conf = ::RbConfig::CONFIG
@@ -70,30 +66,15 @@ module Gem::BUNDLED_GEMS
[::Kernel.singleton_class, ::Kernel].each do |kernel_class|
kernel_class.send(:alias_method, :no_warning_require, :require)
kernel_class.send(:define_method, :require) do |name|
-
- message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names)
- begin
- result = kernel_class.send(:no_warning_require, name)
- rescue LoadError => e
- result = e
- end
-
- # Don't warn if the gem is optional dependency and not found in the Bundler environment.
- if !(result.is_a?(LoadError) && OPTIONAL[name]) && message
+ if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names)
if ::Gem::BUNDLED_GEMS.uplevel > 0
Kernel.warn message, uplevel: ::Gem::BUNDLED_GEMS.uplevel
else
Kernel.warn message
end
end
-
- if result.is_a?(LoadError)
- raise result
- else
- result
- end
+ kernel_class.send(:no_warning_require, name)
end
-
if kernel_class == ::Kernel
kernel_class.send(:private, :require)
else