From 1d3221ad289af51af8c246904d42a5d0f31e3c2b Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 13 May 2025 16:52:03 -0700 Subject: [PATCH] [ruby/erb] Give up on using resolve_feature_path Apparently `$LOAD_PATH.resolve_feature_path('erb/escape')` returns true for miniruby but `require 'erb/escape'` fails on it. I still don't want to check it and rescue LoadError at the same time because the code looks too complicated. Let me just rescue LoadError for platforms that don't build native extensions. https://github.com/ruby/erb/commit/3081c6b20f --- lib/erb/util.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/erb/util.rb b/lib/erb/util.rb index dc9ab3831b..42c7a57622 100644 --- a/lib/erb/util.rb +++ b/lib/erb/util.rb @@ -10,9 +10,10 @@ require 'cgi/escape' # Load or define ERB::Escape#html_escape. # We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM. -if $LOAD_PATH.resolve_feature_path('erb/escape') +# miniruby (used by CRuby build scripts) also fails to load erb/escape.so. +begin require 'erb/escape' -else +rescue LoadError # ERB::Escape # # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope