Skip to content

Commit

Permalink
Improve the Kernel#require patch to avoid warnings
Browse files Browse the repository at this point in the history
Fix: #461

Also neither Rubygems nor Zeitwerk bother decorating
`Kernel.require`, and no-one requires with `Kernel.require` so
likely not worth it, and if anything that offers an escape hatch to
bypass Bootsnap.
  • Loading branch information
byroot committed Dec 14, 2023
1 parent 5edf266 commit dfe9a75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/bootsnap/load_path_cache/core_ext/kernel_require.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 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 redefinition warnings

def require(path)
return require_without_bootsnap(path) unless Bootsnap::LoadPathCache.enabled?
Expand Down Expand Up @@ -34,4 +34,6 @@ def require(path)
return ret
end
end

private :require
end

0 comments on commit dfe9a75

Please sign in to comment.