Skip to content
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

Improve the Kernel#require patch to avoid warnings #462

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Improved the `Kernel#require` decorator to not cause a method redefinition warning. See #461.

# 1.17.0

* Ensure `$LOAD_PATH.dup` is Ractor shareable to fix an conflict with `did_you_mean`.
Expand Down
8 changes: 5 additions & 3 deletions lib/bootsnap/load_path_cache/core_ext/kernel_require.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

module Kernel
module_function
alias_method :require_without_bootsnap, :require

alias_method(:require_without_bootsnap, :require)
alias_method :require, :require # Avoid method redefinition warnings

def require(path)
def require(path) # rubocop:disable Lint/DuplicateMethods
return require_without_bootsnap(path) unless Bootsnap::LoadPathCache.enabled?

string_path = Bootsnap.rb_get_path(path)
Expand Down Expand Up @@ -34,4 +34,6 @@ def require(path)
return ret
end
end

private :require
end
Loading