8000 Only `warn` about bundled gems when require succeeds by deivid-rodriguez · Pull Request #11550 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Only warn about bundled gems when require succeeds #11550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Only warn about bundled gems when require succeeds
  • Loading branch information
deivid-rodriguez committed Sep 4, 2024
commit 79dd7c6929db4785ec6ff4ec9183dc6e92a41656
7 changes: 5 additions & 2 deletions lib/bundled_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ def self.replace_require(specs)
[::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|
if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names)
result = kernel_class.send(:no_warning_require, name)

if result && 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
kernel_class.send(:no_warning_require, name)

result
end
if kernel_class == ::Kernel
kernel_class.send(:private, :require)
Expand Down
0