From dfe9a756679cf250c20617d9564a87a971d4a3c4 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 14 Dec 2023 10:19:05 +0100 Subject: [PATCH] Improve the `Kernel#require` patch to avoid warnings Fix: https://github.com/Shopify/bootsnap/issues/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. --- lib/bootsnap/load_path_cache/core_ext/kernel_require.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb b/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb index 034a1ff..44d3285 100644 --- a/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +++ b/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb @@ -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? @@ -34,4 +34,6 @@ def require(path) return ret end end + + private :require end